Spring @Enable模塊驅(qū)動原理及使用實(shí)例
Spring @Enable 模塊概覽
框架實(shí)現(xiàn) @Enable注解模塊 激活模塊 Spring Framework @EnableWebMvc Web MVC 模塊 @EnableTransactionManagement 事務(wù)管理模塊 @EnableCaching Caching 模塊 @EnableMBeanExport JMX 模塊 @EnableAsync 異步處理模塊 @EnableWebFlux Web Flux 模塊 @EnableAspectJAutoProxy AspectJ 代理模塊 Spring Boot @EnableAutoConfiguration 自動裝配 @EnableManagementContext Actuator 管理模塊 @EnableConfigurationProperties 配置屬性綁定模塊 @EnableOAuth2Sso OAuth2 單點(diǎn)登錄模塊 Spring Cloud @EnableEurekaServer Eureka 服務(wù)器模塊 @EnableConfigServer 配置服務(wù)器模塊 @EnableFeignClients Feign 客戶端模塊 @EnableZuulProxy 服務(wù)網(wǎng)關(guān)Zuul 模塊 @EnableCircuitBreaker 服務(wù)熔斷模塊
理解 @Enable 以 @EnableWebMVC 為例進(jìn)行理解
定義如下:
@Retention(RetentionPolicy.RUNTIME)@Target(ElementType.TYPE)@Documented@Import(DelegatingWebMvcConfiguration.class)public @interface EnableWebMvc {}
發(fā)現(xiàn)該注解中引入的 DelegatingWebMvcConfiguration.class
@Configuration(proxyBeanMethods = false)public class DelegatingWebMvcConfiguration extends WebMvcConfigurationSupport {...}
public class WebMvcConfigurationSupport implements ApplicationContextAware, ServletContextAware {@Bean@SuppressWarnings('deprecation')public RequestMappingHandlerMapping requestMappingHandlerMapping( @Qualifier('mvcContentNegotiationManager') ContentNegotiationManager contentNegotiationManager, @Qualifier('mvcConversionService') FormattingConversionService conversionService, @Qualifier('mvcResourceUrlProvider') ResourceUrlProvider resourceUrlProvider) { ...}...}
其中 實(shí)現(xiàn)類 WebMvcConfigurationSupport.java 中 預(yù)定義了 多個 Spring Bean 對象,
隨著 @EnableWebMVC 驅(qū)動注解的加載而被加載到 Spring 上下文中從而實(shí)現(xiàn) Spring Web MVC的功能。
以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持好吧啦網(wǎng)。
相關(guān)文章:
1. IDEA 程序包不存在,找不到符號但是明明存在對應(yīng)的jar包(問題分析及解決方案)2. 深入理解Android熱修復(fù)技術(shù)原理之資源熱修復(fù)技術(shù)3. 6個常見的 PHP 安全性攻擊實(shí)例和阻止方法4. Django-silk性能測試工具安裝及使用解析5. 用vue 實(shí)現(xiàn)手機(jī)觸屏滑動功能6. Django Session和Cookie分別實(shí)現(xiàn)記住用戶登錄狀態(tài)操作7. 前端ajax請求+后端java實(shí)現(xiàn)的下載zip壓縮包功能示例8. ASP.NET MVC實(shí)現(xiàn)登錄后跳轉(zhuǎn)到原界面9. HTML基礎(chǔ)知識總結(jié)10. 虛機(jī)服務(wù)中常見Asp.Net低級錯誤一覽
