Blog

WebMvcAutoConfiguration で設定されるべき項目が設定されねーぞ!! ってときは @EnableWebMvc ついてないか確認しよう

WebMvcAutoConfiguration/webjars/** に対するパス設定などをしてくれているはずなのに、なぜか有効にならない。。という場合、@EnableWebMvc がついてないか確認しよう。

If you want to keep Spring Boot MVC features, and you just want to add additional MVC configuration (interceptors, formatters, view controllers etc.) you can add your own @Configuration class of type WebMvcConfigurerAdapter, but without @EnableWebMvc. If you wish to provide custom instances of RequestMappingHandlerMapping, RequestMappingHandlerAdapter or ExceptionHandlerExceptionResolver you can declare a WebMvcRegistrationsAdapter instance providing such components.

http://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-developing-web-applications.html#boot-features-spring-mvc-auto-configuration

without @EnableWebMvc...!!!

@EnableWebMvc ついた WebMvcConfigurerAdapter があるとデフォルトの設定が諸々オフになって不便になる。/webjars/** もマッピングされなくなる。ウケる。