I'm using SpringBoot 1.3.5 with maven.
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.3.5.RELEASE</version>
</parent>
And devtools
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
</dependency>
I'm using Intellij IDEA 2016.2, previously 2014 with same problem.
I'm running my springboot app from Intellij Idea, first launch everything is well loaded and works, I can access my static pages and my 2 Rest Controllers work.
2016-08-18 15:27:58.771 INFO 26626 --- [ restartedMain] s.w.s.m.m.a.RequestMappingHandlerAdapter : Looking for @ControllerAdvice: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@469d0c02: startup date [Thu Aug 18 15:27:57 CEST 2016]; root of context hierarchy
2016-08-18 15:27:58.789 INFO 26626 --- [ restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/authentication/introspect],methods=[GET]}" onto public com.myapp.models.TokenIntrospection com.myapp.resources.AuthenticationResources.introspectToken(java.lang.String)
2016-08-18 15:27:58.790 INFO 26626 --- [ restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/configuration],methods=[GET]}" onto public com.myapp.models.AppConfiguration com.myapp.resources.ConfigurationResources.getConfiguration()
2016-08-18 15:27:58.792 INFO 26626 --- [ restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error]}" onto public org.springframework.http.ResponseEntity<java.util.Map<java.lang.String, java.lang.Object>> org.springframework.boot.autoconfigure.web.BasicErrorController.error(javax.servlet.http.HttpServletRequest)
2016-08-18 15:27:58.793 INFO 26626 --- [ restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error],produces=[text/html]}" onto public org.springframework.web.servlet.ModelAndView org.springframework.boot.autoconfigure.web.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)
Because simply "Make Project" doesn't work well for static reload, I use "Rebuild Project" and sometimes, when app restart, I don't have my controllers mapped, sometimes one is missing, sometimes both are missing.
I don't have any clue about this :(
EDIT
@Morfic solutions did not work, so I used the Intellij local server to serve static contents and gulp-livereload instead of spring-dev-tools.
I just had to manage REST calls in JS when I'm in dev mode because REST resources are on localhost:8080 but my statics on localhost:63342, and enable CORS in my springboot (with a flag in properties file to enable CORS or not).
@Configuration
public class CorsConfig extends WebMvcConfigurerAdapter {
@Value("${cors.enabled}")
private boolean corsEnabled;
@Override
public void addCorsMappings(CorsRegistry registry) {
super.addCorsMappings(registry);
if(corsEnabled) {
registry.addMapping("/**")
.allowedOrigins("*")
.allowedMethods("GET", "PUT", "POST", "DELETE", "OPTIONS")
.allowedHeaders("Origin", "X-Requested-With", "Content-Type", "Accept", "Authorization")
.allowCredentials(true)
.maxAge(3600L);
}
}
}
So question still pending for a working solution.