The type WebMvcConfigurerAdapter is deprecated springboot攔截器


The type WebMvcConfigurerAdapter is deprecated

WebMvcConfigurerAdapter 被棄用了,看一下文檔。

 * @deprecated as of 5.0 {@link WebMvcConfigurer} has default methods (made
 * possible by a Java 8 baseline) and can be implemented directly without the
 * need for this adapter

  可以采用直接實現WebMvcConfigurer接口的方式,而不用使用WebMvcConfigurerAdapter 

 

public class MyWebAppConfigurer implements WebMvcConfigurer {

	@Override
	public void addInterceptors(InterceptorRegistry registry) {
		// 多個攔截器組成一個攔截器鏈
		// addPathPatterns 用於添加攔截規則
		// excludePathPatterns 用戶排除攔截
		// RequestInterceptor()為自己定義的攔截器
		registry.addInterceptor(new RequestInterceptor()).addPathPatterns("/**");
	}
}

  

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM