Andrew Kim
Andrew Kim's Blog

Andrew Kim's Blog

How to address Spring Boot + Thymeleaf : 'Cannot resolve symbol' in template in IntelliJ IDEA

How to address Spring Boot + Thymeleaf : 'Cannot resolve symbol' in template in IntelliJ IDEA

Andrew Kim's photo
Andrew Kim
·Feb 21, 2022·

1 min read

The title describes the problem pretty much... In Spring Boot, when using Thymeleaf as template engine, the referenced variables in the template are marked as errors in the IntelliJ IDEA's Problem Pane. Below is a screenshot of the case:

Screen Shot 2022-02-21 at 3.20.51 PM.png

Screen Shot 2022-02-21 at 3.21.02 PM.png

When compiled, the template displays alright despite the problems. But it doesn't feel right to leave the reported problems in there. How can I address these unresolved symbols in the template?

The solution is quite easy. (Found the solution here - StackOverflow).

SOLUTION: Replace

<html lang="en" xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">

with

<html lang="en" xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://thymeleaf.org">

The only difference is in the namespace - just removing that 'www' infix.

Why does it do the trick? I haven't figured it out but it works and the cause is low in priority for me... and I just wanted to leave a note for myself and for anyone interested in addressing the issue.

Happy Coding!

 
Share this