Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Thymeleaf cache set to false not working

I have a spring application under development. The configuration of the project is as follows:

  • spring-dev-tools dependency is one of the maven dependencies
  • thymeleaf dependency is added through spring-boot-starter, that is org.springframework.boot:spring-boot-starter-thymeleaf
  • I have explicitly disabled template cache with spring.thymeleaf.cache=false
  • The src/main/resources folder is marked as resource in my IntelliJ IDEA project.

I am using IntelliJ IDEA project to run the application. When I run the application, I can see in the console output that: LiveReload server is running on port 35729
Although, it seems like all my configuration is correct, the running application is not loading any changes I made to the templates while it is running.

like image 467
Vihari Piratla Avatar asked Oct 22 '25 17:10

Vihari Piratla


2 Answers

If you are using Spring Tool Suite 4, you need to implement the following in your application.properties to disable the cache from Thymeleaf:

spring.thymeleaf.cache=false
spring.thymeleaf.prefix=file:src/main/resources/templates/

Adding the spring.thymeleaf.prefix value worked for me.

For more information about the solution:

https://github.com/spring-projects/spring-boot/issues/34#issuecomment-316295791

like image 102
pableiros Avatar answered Oct 25 '25 06:10

pableiros


The LiveReload server loads any changes only when one of the files on the classpath is modified Spring Doc.
Though I have resources, the folder containing templates folder, on the classpath, the changes to the html files in templates folder are not reflected in the running application.
What worked for me is to also add src/main/resources/templates to the classpath i.e. marked as resource in IntelliJ

Thanks

like image 22
Vihari Piratla Avatar answered Oct 25 '25 07:10

Vihari Piratla



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!