1

I followed the demo of spring loaded from here http://www.youtube.com/watch?v=GTrNkhVnJBU

It works great for class changes but is there a way to get it working for the view layer, specifically Spring MVC with Thymeleaf templates.

Bahadır Yağan
  • 5,577
  • 3
  • 35
  • 39

3 Answers3

3

Thymeleaf pages are no JAVA-Sources, so it can't work. However Thymeleaf can deal with the problem without an enhancements. It's just a question of configuration

@Bean()
public ServletContextTemplateResolver templateResolver() {
    final ServletContextTemplateResolver resolver =
            new ServletContextTemplateResolver();
    resolver.setPrefix("/WEB-INF/templates/");
    resolver.setSuffix(".html");
    resolver.setTemplateMode("HTML5");
    resolver.setCacheable(cacheable);
    resolver.setCharacterEncoding("UTF-8");
    return resolver;
}

Above you can see my configuration in FuWeSta-Sample. Just add resolver.setCacheable(false);

niels
  • 7,321
  • 2
  • 38
  • 58
1

You can simply disable the cache for Thymeleaf.

For more details here is a post that treats this topic: http://blog.netgloo.com/2014/05/21/hot-swapping-in-spring-boot-with-eclipse-sts/

Fred K
  • 13,249
  • 14
  • 78
  • 103
0

You can turn down caching by adding the cacheable property to false. (True by default)

<bean id="templateResolver"
    class="org.thymeleaf.templateresolver.ServletContextTemplateResolver">
    <property name="prefix" value="/WEB-INF/templates/" />
    <property name="suffix" value=".html" />
    <property name="templateMode" value="HTML5" />
    <!-- Disable Caching of templates -->
    <property name="cacheable" value="false" />
</bean>
Krishna Vedula
  • 1,643
  • 1
  • 27
  • 31