In my Spring Boot project I have the following structure:
- src
- main
- java
- resources
- static
- css
- js
- img
-
Did you also read the chapter for the "LiveReload"? You'll need to make sure that your LiveReload Server is started from the SpringBoot-Devtools. You can also use the browser plugin from LiveReload.com. Or you could use the Plugin from the Chrome Web Store. See Chapter LiveReload for more details.
Finally found the solution. It was much simpler than I thought.
Since I'm using war packaging I can use webapp's default behaviour. Everything under source folders trigger a restart, but resources under webapp are fetched at runtime, so there is no need to reload anything.
I just placed my static content under /webapp/static and then added the resource handler:
@Configuration
public class MvcConfig implements WebMvcConfigurer {
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("/static/**").addResourceLocations("/static/");
}
}
Just don't use the default Spring Boot placement for statics (basically anything under resources) and you'll be fine.