Introduction
Thymeleaf is a natural template engine that is often used in modern java-server-side applications that are running in web and standalone environments. Ease of natural templating gives the upperhand to pick Thymeleaf over other frameworks in Java Serverside application development. Spring provides support to thmyeleaf development. Spring boot has its own starter dependency for thymeleaf. While we develop thmyeleaf templates using spring boot applications, Front End Developers cannot see the changes that are made in the resources while the application is running. But the changes don't take effect in the browser until the application is reloaded or restarted.
Solution
We can solve this templating-resources-reloading without application restart. Spring boot uses properties in which we have to just disable the cache for Thymeleaf. Below are the steps to achieve these.
Step 2: We just need to update pom.xml and set spring-boot-maven-plugin 'addResources' configuration to true.
When addResources is enabled, any src/main/resources folder will be added to the application classpath when you run the application and any duplicate found in target/classes will be removed. This allows hot refreshing of resources and ensures the application picks from resources folder rather than the classpath resources.
Assumption : Spring Boot (1.5.6), Thymeleaf (3.0.6), Maven Projects
Thymeleaf is a natural template engine that is often used in modern java-server-side applications that are running in web and standalone environments. Ease of natural templating gives the upperhand to pick Thymeleaf over other frameworks in Java Serverside application development. Spring provides support to thmyeleaf development. Spring boot has its own starter dependency for thymeleaf. While we develop thmyeleaf templates using spring boot applications, Front End Developers cannot see the changes that are made in the resources while the application is running. But the changes don't take effect in the browser until the application is reloaded or restarted.
Solution
We can solve this templating-resources-reloading without application restart. Spring boot uses properties in which we have to just disable the cache for Thymeleaf. Below are the steps to achieve these.
Step 1: Disable the cache by setting the spring.thymeleaf.cache = false in the application.properties file.
The property just disables the Thmyeleaf caching template in Spring applications. If you are working on different(dev, prod, staging) environments, make sure you are updating relevant environment properties so that your production environment still caches the Thymeleaf template.Step 2: We just need to update pom.xml and set spring-boot-maven-plugin 'addResources' configuration to true.
When addResources is enabled, any src/main/resources folder will be added to the application classpath when you run the application and any duplicate found in target/classes will be removed. This allows hot refreshing of resources and ensures the application picks from resources folder rather than the classpath resources.
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<addResources>true</addResources>
</configuration>
</plugin>
</plugins>
</build>
Assumption : Spring Boot (1.5.6), Thymeleaf (3.0.6), Maven Projects
Lucky Lady Bingo Slot Machines - JTM Hub
ReplyDeleteWelcome to J.T. Bingo. Your chance to 파주 출장안마 win real money playing 진주 출장샵 and winning at the casino with 천안 출장안마 these high-quality, fun 순천 출장샵 casino games. 군산 출장마사지
Amazing post, thanks for sharing such informative article. Useful and interesting. Take look at this too ecommerce development company in dubai. Thanks!
ReplyDeletepg สล็อต เกมสล็อตออนไลน์ได้รับความนิยมอย่างมากในปัจจุบัน โดยเฉพาะจาก PG SLOT ซึ่งเป็นนักพัฒนาเกมชื่อดังที่มีความรู้สึกทันสมัยและคุณภาพเยี่ยม ผ่านอุปกรณ์มือถือที่ทันสมัยและสะดวกสบาย
ReplyDelete