@EnableAutoConfiguration自动装配以及查看装配结果
程序员文章站
2022-03-02 14:37:49
...
作者邮箱: [email protected]
@EnableAutoConfiguration
@EnableAutoConfiguration是类级注释。 这个注释告诉Spring Boot根据你添加的jar依赖关系“猜测”你将如何配置Spring(Spring Boot自动配置尝试根据您添加的jar依赖项自动配置Spring应用程序)。例如你在pom.xml引入了spring-boot-starter-web,Spring将自动引入添加Tomcat和Spring MVC相关jar依赖,因此自动配置将假设您正在开发Web应用程序并相应地设置了默认的Spring环境。具体请查看
spring-boot-autoconfigure:xxx.RELEASE.jar中的META-INF/spring.factories中的EnableAutoConfiguration配置
研究完后, 记得教教我啊, 师傅 !!!
一: 可以通过actuator进行获取配置信息进行监控.
二: 如果您需要了解当前正在应用的自动配置以及原因,请启动您的应用程序使用–debug开关。 这将为选择的核心记录器启用调试日志并记录自动配置报告到控制台。
可在applycation.properties中配置 debug=true
或者在jvm中添加参数 -Ddebug=true
控制台输出结果:
============================
CONDITIONS EVALUATION REPORT -> 自动装配环境报告
============================
Positive matches: (已启用的自动装配)
-----------------
CodecsAutoConfiguration matched:
- @ConditionalOnClass found required class 'org.springframework.http.codec.CodecConfigurer'; @ConditionalOnMissingClass did not find unwanted class (OnClassCondition)
CodecsAutoConfiguration.JacksonCodecConfiguration matched:
- @ConditionalOnClass found required class 'com.fasterxml.jackson.databind.ObjectMapper'; @ConditionalOnMissingClass did not find unwanted class (OnClassCondition)
CodecsAutoConfiguration.JacksonCodecConfiguration#jacksonCodecCustomizer matched:
- @ConditionalOnBean (types: com.fasterxml.jackson.databind.ObjectMapper; SearchStrategy: all) found bean 'jacksonObjectMapper' (OnBeanCondition)
DispatcherServletAutoConfiguration matched:
- @ConditionalOnClass found required class 'org.springframework.web.servlet.DispatcherServlet'; @ConditionalOnMissingClass did not find unwanted class (OnClassCondition)
- found ConfigurableWebEnvironment (OnWebApplicationCondition)
DispatcherServletAutoConfiguration.DispatcherServletConfiguration matched:
- @ConditionalOnClass found required class 'javax.servlet.ServletRegistration'; @ConditionalOnMissingClass did not find unwanted class (OnClassCondition)
- Default DispatcherServlet did not find dispatcher servlet beans (DispatcherServletAutoConfiguration.DefaultDispatcherServletCondition)
DispatcherServletAutoConfiguration.DispatcherServletRegistrationConfiguration matched:
- @ConditionalOnClass found required class 'javax.servlet.ServletRegistration'; @ConditionalOnMissingClass did not find unwanted class (OnClassCondition)
- DispatcherServlet Registration did not find servlet registration bean (DispatcherServletAutoConfiguration.DispatcherServletRegistrationCondition)
Negative matches: (未启用的自动配置)
-----------------
ActiveMQAutoConfiguration:
Did not match:
- @ConditionalOnClass did not find required classes 'javax.jms.ConnectionFactory', 'org.apache.activemq.ActiveMQConnectionFactory' (OnClassCondition)
AopAutoConfiguration:
Did not match:
- @ConditionalOnClass did not find required classes 'org.aspectj.lang.annotation.Aspect', 'org.aspectj.lang.reflect.Advice', 'org.aspectj.weaver.AnnotatedElement' (OnClassCondition)
ArtemisAutoConfiguration:
Did not match:
- @ConditionalOnClass did not find required classes 'javax.jms.ConnectionFactory', 'org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory' (OnClassCondition)
BatchAutoConfiguration:
Did not match:
- @ConditionalOnClass did not find required classes 'org.springframework.batch.core.launch.JobLauncher', 'org.springframework.jdbc.core.JdbcOperations' (OnClassCondition)
Exclusions: (以排除的自动配置)
-----------
None
Unconditional classes: (无条件类)
----------------------
org.springframework.boot.autoconfigure.context.ConfigurationPropertiesAutoConfiguration
org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration
org.springframework.boot.autoconfigure.info.ProjectInfoAutoConfiguration
上一篇: springboot(24)@ConfigurationProperties 与 @Value
下一篇: springboot If you want an embedded database please put a supported one on the classpath
推荐阅读
-
第五讲:AbstractBean以及Ioc常见注解使用和自动装配
-
第五讲:AbstractBean以及Ioc常见注解使用和自动装配
-
springBoot2数据库连接池自动装配原理,以及如何配置使用其他的数据库连接池(druid)为例
-
组件扫描以及自动装配
-
SpringBoot核心机制五、EnableAutoConfiguration属性自动装配
-
Springboot 自动装配@EnableAutoConfiguration 学习
-
boot 自动装配原理 @EnableAutoConfiguration
-
Spring之Bean的装配——介绍以及自动装配
-
@EnableAutoConfiguration自动装配以及查看装配结果