I tried all tips and tricks that I found here and in docs, but still no luck. I have Spring webapp with Thymeleaf. Resources and templates are not reloaded when I call update in IDEA (it says nothing to reload). I can then press ctrl+f5 in a browser like crazy, changes are just not there.
Everything is configured in one Java class like this:
@EnableWebMvc
public class MvcConfig extends WebMvcConfigurerAdapter implements ApplicationContextAware {
My folder structure now looks like this, but I also tried to put the resources without "static" folder or to webapp/resources.
ResourceHandlerRegistry:
@Override
public void addResourceHandlers(final ResourceHandlerRegistry registry) {
super.addResourceHandlers(registry);
registry.addResourceHandler("/img/**").addResourceLocations("classpath:/static/img/");
registry.addResourceHandler("/css/**").addResourceLocations("classpath:/static/css/");
registry.addResourceHandler("/js/**").addResourceLocations("classpath:/static/js/");
}
I specified cache=false in both application.properties:
spring.thymeleaf.cache=false
and in mentioned MvcConfig class:
@Bean
public SpringResourceTemplateResolver templateResolver() {
SpringResourceTemplateResolver templateResolver = new SpringResourceTemplateResolver();
templateResolver.setApplicationContext(this.applicationContext);
templateResolver.setPrefix("/WEB-INF/templates/");
templateResolver.setSuffix(".html");
templateResolver.setTemplateMode(TemplateMode.HTML);
templateResolver.setCacheable(false);
return templateResolver;
}
According to some answers on SO i added dependency for devtools:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<version>1.4.1.RELEASE</version>
<optional>true</optional>
</dependency>
Still not working. Some said to add maven boot plugin with addResources=true, so I did:
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>1.4.1.RELEASE</version>
<configuration>
<addResources>true</addResources>
</configuration>
</plugin>
My Idea is set properly I guess, because when I call update, my Java classes are reloaded immediately. Only resources and html files are not, I must restart server for it. Actualy *.html files are not so big a deal, but to restart server after every small css and js change is slowing me down a lot, and as I lost almost 15 hours figuring out what is wrong, it started to be really frustrating.
Any help will be greatly appreciated.