WebMvcConfigurationSupport是webmvc的配置类,如果在springboot项目中,有配置类继承了WebMvcConfigurationSupport,那么webmvc的自动配置类WebMvcAutoConfiguration就会失效

    1. @Slf4j
    2. @Configuration
    3. public class WebMvcConfig extends WebMvcConfigurationSupport {
    4. @Override
    5. protected void addResourceHandlers(ResourceHandlerRegistry registry) {
    6. log.info("开始静态资源注册");
    7. //addResourceHandler资源通配符,代表浏览器url后的资源路径 比如:http://xxx:80/backend/index.html
    8. //addResourceLocations(资源地址) 地址映射 比如:resources下的backend下所有的资源
    9. registry.addResourceHandler("/backend/**").addResourceLocations("classpath:/backend/");
    10. registry.addResourceHandler("/front/**").addResourceLocations("classpath:/front/");
    11. }
    12. }