Question

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.

Était-ce utile?

La solution

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);

Autres conseils

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/

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>
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top