关于Spring Boot的静态资源


在Spring Boot 2.0版本之前,使用WebMvcConfigurerAdapter 可以设置静态资源的映射规则等操作,然而Spring Boot 2.0版本以后由于WebMvcConfigurerAdapter废弃,则换成了 extends WebMvcConfigurationSupport 或者 implements WebMvcConfigurer。2.0版本之前使用如图

2.0版本之后使用 WebMvcConfigurationSupport如图所示

2.0版本之后使用WebMvcConfigurer如图所示

并且观察WebMvcAutoConfiguration 源码我们可以看到如下图所示,当我们使用WebMvcConfigurationSupport时,Spring Boot不会进行WebMvcAuotConfiguration中的自动配置。


分享到:


相關文章: