Spring @Enable模塊驅(qū)動(dòng)原理及使用實(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 | 自動(dòng)裝配 |
| @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ù)定義了 多個(gè) Spring Bean 對(duì)象,
隨著 @EnableWebMVC 驅(qū)動(dòng)注解的加載而被加載到 Spring 上下文中從而實(shí)現(xiàn) Spring Web MVC的功能。
以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
相關(guān)文章
Pytorch 數(shù)據(jù)加載與數(shù)據(jù)預(yù)處理方式
今天小編就為大家分享一篇Pytorch 數(shù)據(jù)加載與數(shù)據(jù)預(yù)處理方式,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧2019-12-12
python使用Apriori算法進(jìn)行關(guān)聯(lián)性解析
這篇文章主要為大家分享了python使用Apriori算法進(jìn)行關(guān)聯(lián)性的解析,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2017-12-12
Python圖像處理之簡(jiǎn)單畫板實(shí)現(xiàn)方法示例
這篇文章主要介紹了Python圖像處理之簡(jiǎn)單畫板實(shí)現(xiàn)方法,結(jié)合實(shí)例形式分析了Python基于cv2模塊與numpy模塊的數(shù)值計(jì)算及矩形圖形繪制簡(jiǎn)單操作技巧,需要的朋友可以參考下2018-08-08
Python BautifulSoup 節(jié)點(diǎn)信息
這篇文章主要介紹了Python BautifulSoup 節(jié)點(diǎn)信息,文章圍繞主題展開詳細(xì)的內(nèi)容介紹,具有一定的參考價(jià)值,需要的小伙伴可以參考一下2022-08-08
scrapy-redis分布式爬蟲的搭建過(guò)程(理論篇)
這篇文章主要介紹了scrapy-redis分布式爬蟲的搭建過(guò)程(理論篇),文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2020-09-09
python實(shí)現(xiàn)數(shù)據(jù)分析與建模
這篇文章主要介紹了python實(shí)現(xiàn)數(shù)據(jù)分析與建模功能,本文給大家介紹的非常詳細(xì),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2019-07-07
Python中xrange與yield的用法實(shí)例分析
這篇文章主要介紹了Python中xrange與yield的用法,結(jié)合實(shí)例形式較為詳細(xì)的分析了range和xrange功能、使用方法與相關(guān)注意事項(xiàng),需要的朋友可以參考下2017-12-12

