Spring boot devtools with Spring mvc

405 Views Asked by At

Is it possible to use spring-boot-devtools in a Spring MVC project?

I basically want the .jsp pages and other static resources to reload automatically without server restart.

1

There are 1 best solutions below

0
On

try with these : add a configuration bean and see if your jsp files are getting loaded

@Configuration
class WebMvcConfigurer extends WebMvcConfigurerAdapter {
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/dist/*.js").addResourceLocations(
            "file:src/main/dist/"
        );
    }
}

or in the pom.xml , along with the spring-boot-maven-plugin add this

<configuration>
    <addResources>true</addResources>
</configuration>

I am not sure where you are putting your static content in the classpath , may be in src/main/resources/public folder. Instead put them in src/main/webapp, the same as you would any other Java web app. The embedded Tomcat will automatically reload them whenever they change.