查看Spring Boot自动配置类生效情况

通过在配置文件中设置debug属性为true,让控制台打印自动配置报告,就可以查看自动配置类的生效情况。

1. 首先设置配置文件:

.yml文件

debug: true
# -------------
server:
  port: 8088

.properties文件

debug=true
# -------------
server.port=8088
2. 查看控制台输出:

输出分为四种:

  1. Positive matches 匹配生效的配置类;
CodecsAutoConfiguration matched:
   - @ConditionalOnClass found required class 'org.springframework.http.codec.CodecConfigurer' (OnClassCondition)

CodecsAutoConfiguration.JacksonCodecConfiguration matched:
   - @ConditionalOnClass found required class 'com.fasterxml.jackson.databind.ObjectMapper' (OnClassCondition)

...
  1. Negative matches 未匹配生效的配置类;
ActiveMQAutoConfiguration:
   Did not match:
      - @ConditionalOnClass did not find required class 'javax.jms.ConnectionFactory' (OnClassCondition)

AopAutoConfiguration:
   Did not match:
      - @ConditionalOnClass did not find required class 'org.aspectj.lang.annotation.Aspect' (OnClassCondition)

...
  1. Exclusions 被排除的配置类(无特殊设置情况下为None);
  2. Unconditional classes 无条件配置类(即基本配置类,不需要匹配条件,默认生效)。
org.springframework.boot.autoconfigure.context.ConfigurationPropertiesAutoConfiguration

org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration

org.springframework.boot.autoconfigure.info.ProjectInfoAutoConfiguration
  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值