Spring Boot applications forget where the Thymeleaf templates are
So my Thymeleaf templates are (as always) in src/main/resources/templates. I'd like them to be in src/main/html, but there you are.
The problem is that every few weeks, seemingly at random, the Spring Boot application (and it's not always the same app. I have several I'm developing.) start failing tests with this error org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.thymeleaf.exceptions.TemplateInputException: Error resolving template "fragments/header".
Normally, the template it's referring to is a main template - this time it's a fragment, which makes it extra confusing, since it apparently knows perfectly well where the main template is, but then forgets it by the time it tries to find the fragment. (which is in the subfolder "fragments" and is called header.html. It's just a <head> element with a th:template="header" field inside.
Every time I get this issue I spend at least an hour trying to get it to work. It always works in Gradle, so I know it's not the code. In fact, I can run the app and all tests right now with "gradle bootRun" or "grade test" without a single issue! The way I fix it is normally by doing a "invalidate caches and restart" or just deleting the .idea-folder. But I don't want to have to keep doing that! I want to find out why it happens, and make it stop happening!
... help...
Please sign in to leave a comment.
To resolve this kind of issue we'll need a reproducible test case (MCVE), please file a ticket at https://youtrack.jetbrains.com/issues/IDEA and attach it.