Issue
I have the following controller:
@Controller
public class ConfigController {
@GetMapping("/")
public String index() {
return "config";
}
}
However, I receive the following error when going to the route /
:
There was an unexpected error (type=Internal Server Error, status=500).
Error resolving template [config], template might not exist or might not be accessible by any of the configured Template Resolvers
org.thymeleaf.exceptions.TemplateInputException: Error resolving template [config], template might not exist or might not be accessible by any of the configured Template Resolvers
I have a config.html
file inside of resources/templates
:
My pom.xml file: https://pastebin.com/yqYYuXWh
What am I doing wrong?
I have already tried adding a .html
to the return of the controller function, but it still doesn't work.
After removing the spring-web dependency (I already had spring-boot-starter-web
) I now get the following error when starting spring:
Cannot find template location: classpath:/templates/ (please add some templates or check your Thymeleaf configuration)
Solution
The issue is in your pom.xml file.
By adding this block to your build
;
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
<includes>
<include>application.properties</include>
</includes>
</resource>
</resources>
You have overriden spring-boot-starter-parent
's own resources
block and caused it to include application.properties
and nothing else. Remove it from your pom.xml and delete your target directory.
Answered By - Idan Elhalwani
Answer Checked By - Dawn Plyler (JavaFixing Volunteer)