關於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中的自動配置。