John Russell
John Russell

Reputation: 1165

Modify Thymleaf template without having to do a server restart

This is a pretty basic question but I can't seem to find it anywhere. Is there a way to make changes to a thymeleaf template such that after a change has been made a simple browser refresh will reflect my changes?

I am currently using jetty and was wondering if this behavior could be replicated to how express + jade behaves.

Thanks so much.

Upvotes: 2

Views: 736

Answers (2)

George Z.
George Z.

Reputation: 6808

In my case I had a FileTemplateResolver in order to make thymeleaf look for templates under mytemplates/ folder, which is not in classpath.

So, doing:

myTemplatesResolver.setCacheable(false);

made it work.

Upvotes: 0

manish
manish

Reputation: 20135

Make sure the Thymeleaf template resolver is configured as follows:

<bean class="org.thymeleaf.templateresolver.ServletContextTemplateResolver">
  <property name="cacheable" value="false"/>
</bean>

Ideally you should do this on a per-environment basis so that local changes are reflected immediately in the browser during development but templates are cached on production for the best possible performance.

Upvotes: 5

Related Questions