Spring Boot 运行原理 – 查看Spring Boot自动配置项

扫码关注公众号:Java 技术驿站

发送:vip
将链接复制到本浏览器,永久解锁本站全部文章

【公众号:Java 技术驿站】 【加作者微信交流技术,拉技术群】
免费领取10G资料包与项目实战视频资料

1 查看Spring Boot自动配置项

Spring Boot 自动配置源代码在spring-boot-autoconfigure-1.5.3.RELEASE.jar内,如图:

20191017100142\_1.png20191017100142\_2.png

如果想知道Spring Boot做了那些自动配置可以在这里看源码。

可以通过下面三种方式查看当前项目中已启用和未启动的自动配置报告:

  1. 运行jar时添加–debug参数:
    java -jar xx.jar --debug
  1. 在application.properties文件中加属性:
    debug=true
  1. 在STS中进行设置,如图:

20191017100142\_3.png20191017100142\_4.png

此时启动会在控制台输出,已启用的自动配置:

    ========================= AUTO-CONFIGURATION REPORT
    ========================= 

    Positive matches:
    ----------------- 
       DefaultValidatorConfiguration#defaultValidator matched:
          - @ConditionalOnMissingBean (types: javax.validation.Validator,org.springframework.validation.Validator; SearchStrategy: all) did not find any beans (OnBeanCondition) 
       DispatcherServletAutoConfiguration matched:
          - @ConditionalOnClass found required class 'org.springframework.web.servlet.DispatcherServlet'; @ConditionalOnMissingClass did not find unwanted class (OnClassCondition)       - @ConditionalOnWebApplication (required) found StandardServletEnvironment (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) ...

未启用的自动配置:

    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' (OnClassCondition) ...

以排除的自动配置

    Exclusions: -----------

     None

无条件类:

    Unconditional classes:
    ----------------------

        org.springframework.boot.autoconfigure.context.ConfigurationPropertiesAutoConfiguration

        org.springframework.boot.autoconfigure.web.WebClientAutoConfiguration

        org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration

        org.springframework.boot.autoconfigure.info.ProjectInfoAutoConfiguration

20191017100142\_5.png


来源:[]()

赞(0) 打赏
版权归原创作者所有,任何形式的转载请联系博主:daming_90:Java 技术驿站 » Spring Boot 运行原理 – 查看Spring Boot自动配置项

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏