在SpringBoot2.0及Spring 5.0 WebMvcConfigurerAdapter已被廢棄,目前找到解決方案就有兩種

1 直接實現WebMvcConfigurer (官方推薦)

例如:java

@Configuration public class WebMvcConfg implements WebMvcConfigurer { //todo }

2 直接繼承WebMvcConfigurationSupport

例如:web

@Configuration public class WebMvcConfg extends WebMvcConfigurationSupport { //todo }


今天查了下官方api 
Deprecated. 
as of 5.0 WebMvcConfigurer has default methods (made possible by a Java 8 baseline) and can be implemented directly without the need for this adapter 
An implementation of WebMvcConfigurer with empty methods allowing subclasses to override only the methods they’re interested in. 
所以推薦第一種方式api

相關文章
相關標籤/搜索