Zeeshan Ahmad
Zeeshan Ahmad

Reputation: 31

Spring Boot devtools Controller mappings are not reloading

I am facing issue while using spring-boot-devtools when application starts spring boot loads all mapping defined in controller.

2015-09-22 21:11:17.752  INFO 1880 --- [  restartedMain] s.w.s.m.m.a.RequestMappingHandlerAdapter : Looking for @ControllerAdvice: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@6f18fa2d: startup date [Tue Sep 22 21:11:02 PKT 2015]; root of context hierarchy
2015-09-22 21:11:17.942  INFO 1880 --- [  restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/properties]}" onto java.util.Properties com.sample.web.HomeController.properties()
2015-09-22 21:11:17.946  INFO 1880 --- [  restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/]}" onto java.lang.String com.sample.web.HomeController.index()
2015-09-22 21:11:17.947  INFO 1880 --- [  restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/employee]}" onto public java.util.List<com.sample.domain.Employee> com.sample.web.HomeController.getEmployee()
2015-09-22 21:11:17.957  INFO 1880 --- [  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)
2015-09-22 21:11:17.957  INFO 1880 --- [  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)

But when there is some change made in controller and build with CTRL + F9 in Intellij IDEA spring-boot-devtools kicks in and reload classes but it do not load controller mapping again.

2015-09-22 21:11:53.492  INFO 1880 --- [  restartedMain] s.w.s.m.m.a.RequestMappingHandlerAdapter : Looking for @ControllerAdvice: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@54e74c05: startup date [Tue Sep 22 21:11:45 PKT 2015]; root of context hierarchy
2015-09-22 21:11:53.549  INFO 1880 --- [  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)
2015-09-22 21:11:53.550  INFO 1880 --- [  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)
2015-09-22 21:11:53.639  INFO 1880 --- [  restartedMain] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]

And when application is accessed following content is showing

Whitelabel Error Page

This application has no explicit mapping for /error, so you are seeing this as a fallback.

Tue Sep 22 21:14:11 PKT 2015 There was an unexpected error (type=Not Found, status=404). No message available

Upvotes: 3

Views: 736

Answers (1)

Robin
Robin

Reputation: 11

I just stumbled across the same problem. Adding a thymeleaf config class solved it for me.

Something like:

@Configuration
public class ThymeleafConfiguration {
    @Bean
    public ITemplateResolver defaultTemplateResolver() {
        TemplateResolver resolver = new FileTemplateResolver();
        resolver.setSuffix(".html");            
        resolver.setPrefix("/home/.../IdeaProjects/.../src/main/resources/templates/" );
        resolver.setTemplateMode("HTML5");
        resolver.setCharacterEncoding("UTF-8");
        resolver.setCacheable(false);
        return resolver;
    }
}

Upvotes: 1

Related Questions