Spring Boot 运行原理

来源:互联网 发布:apache服务器搭建 编辑:程序博客网 时间:2024/06/06 00:14

1 查看Spring Boot自动配置项

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

imageimage

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

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

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

imageimage

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

=========================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
0 0
原创粉丝点击