How to locate Thymeleaf template from spring boot

2 things here : 1. If you are using Maven, and I assume no customizations to folder names. Then the folder name should be src instead of source. 2. Once the folder has been renamed move your templates into 'templates' folder inside src/resources this should run fine.


For Thymeleaf template files put in folder src/main/resources/templates/ and it will work for you also do check out http://www.mkyong.com/spring-boot/spring-boot-hello-world-example-thymeleaf/ . Hope you will find it easy to kick start thymeleaf with spring boot.


The default directory location for thymeleaf templates is:

src/main/resources/templates

The other paths are standard conventions for Spring Boot.

Spring Boot thymeleaf directory structure


Spring Boot includes auto-configuration support for the thymeleaf templating engines, your templates will be picked up automatically from src/main/resources/templates.

if you are customize you template location then use below thymeleaf property configuration available in Spring Boot.

 spring.thymeleaf.check-template=true # Check that the template exists before rendering it.

 spring.thymeleaf.check-template-location=true # Check that the templates location exists.

 spring.thymeleaf.enabled=true # Enable MVC Thymeleaf view resolution.

 spring.thymeleaf.prefix=classpath:/templates/ # Prefix that gets prepended to view names when building a URL.

 spring.thymeleaf.suffix=.html # Suffix that gets appended to view names when building a URL.