'How do I see Thymeleaf template changes in Broadleaf without restarting my server?

I downloaded the community edition of Broadleaf and I'm trying to change some markup in the Thymeleaf templates. (For example: layout/homepage.html). However, when I make a change, I don't see my changes when I refresh my browser unless I restart my Broadleaf site server. I have the same issue when editing JS and CSS.

Is there a setting that needs to be changed to see frontend changes without restarting the server? I'm suspecting some sort of cache setting is preventing the templates from reloading from the file.



Solution 1:[1]

Using the IDE rebuild seems to work with the oob Breadleaf Demo Site when running from a terminal with the spring-boot maven goal:

mvn spring-boot:run

Once it is running, if you update the templates/css inside the IDE with build automatically enabled (important!), then the site does reflect the changes upon refresh.

I verified this works with IntelliJ, Spring Tool Suite, and base Eclipse.

Solution 2:[2]

Sorry for the misleading forum post. The cache settings he's referring to doesn't alleviate the problem you're having. Without Jrebel or some sort of hotswapping mechanism you will not be able to see changes without restarting the server. One thing that might work is if you run the project from your IDE the template changes might show because it may place your changed templates into the Jar that is deployed.

After a google search I did run across this as well https://blog.codeleak.pl/2016/12/thymeleaf-reload-templates-and-static-resources.html. I'm not sure if it works but it's worth a try

Solution 3:[3]

With Broadleaf 6.0.6, I had to add template resolver bean:

@Bean
public BroadleafTemplateResolver devTemplateResolver() {
    BroadleafThemeAwareTemplateResolver resolver = new BroadleafThemeAwareTemplateResolver();
    resolver.setPrefix(Paths.get("src/main/resources/").toUri().toString());
    resolver.setTemplateFolder("webTemplates/");
    resolver.setSuffix(".html");
    resolver.setCharacterEncoding("UTF-8");
    resolver.setCacheable(false);
    resolver.setOrder(10);
    return resolver;
}

That is a "Demo Site" project, SiteConfig.java class.

This bean goes to the top of the list of template resolvers, so chnages to the template files are picked up form src folder, no need to re-build.

Solution 4:[4]

add needs to be done is to disable catching for the template in Thymeleaf. add this to your application properties file.

spring.thymeleaf.cache=false

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2 pequals
Solution 3
Solution 4 majed