============================
CONDITIONS EVALUATION REPORT
============================
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)
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' (OnClassCondition)
- found ConfigurableWebEnvironment (OnWebApplicationCondition)
DispatcherServletAutoConfiguration.DispatcherServletConfiguration matched:
- @ConditionalOnClass found required class 'javax.servlet.ServletRegistration' (OnClassCondition)
- Default DispatcherServlet did not find dispatcher servlet beans (DispatcherServletAutoConfiguration.DefaultDispatcherServletCondition)
DispatcherServletAutoConfiguration.DispatcherServletRegistrationConfiguration matched:
- @ConditionalOnClass found required class 'javax.servlet.ServletRegistration' (OnClassCondition)
- DispatcherServlet Registration did not find servlet registration bean (DispatcherServletAutoConfiguration.DispatcherServletRegistrationCondition)
DispatcherServletAutoConfiguration.DispatcherServletRegistrationConfiguration#dispatcherServletRegistration matched:
- @ConditionalOnBean (names: dispatcherServlet; types: org.springframework.web.servlet.DispatcherServlet; SearchStrategy: all) found bean 'dispatcherServlet' (OnBeanCondition)
EmbeddedWebServerFactoryCustomizerAutoConfiguration matched:
- @ConditionalOnWebApplication (required) found ConfigurableWebEnvironment (OnWebApplicationCondition)
EmbeddedWebServerFactoryCustomizerAutoConfiguration.TomcatWebServerFactoryCustomizerConfiguration matched:
- @ConditionalOnClass found required classes 'org.apache.catalina.startup.Tomcat', 'org.apache.coyote.UpgradeProtocol' (OnClassCondition)
ErrorMvcAutoConfiguration matched:
- @ConditionalOnClass found required classes 'javax.servlet.Servlet', 'org.springframework.web.servlet.DispatcherServlet' (OnClassCondition)
- found ConfigurableWebEnvironment (OnWebApplicationCondition)
ErrorMvcAutoConfiguration#basicErrorController matched:
- @ConditionalOnMissingBean (types: org.springframework.boot.web.servlet.error.ErrorController; SearchStrategy: current) did not find any beans (OnBeanCondition)
ErrorMvcAutoConfiguration#errorAttributes matched:
- @ConditionalOnMissingBean (types: org.springframework.boot.web.servlet.error.ErrorAttributes; SearchStrategy: current) did not find any beans (OnBeanCondition)
ErrorMvcAutoConfiguration.DefaultErrorViewResolverConfiguration#conventionErrorViewResolver matched:
- @ConditionalOnBean (types: org.springframework.web.servlet.DispatcherServlet; SearchStrategy: all) found bean 'dispatcherServlet'; @ConditionalOnMissingBean (types: org.springframework.boot.autoconfigure.web.servlet.error.DefaultErrorViewResolver; SearchStrategy: all) did not find any beans (OnBeanCondition)
ErrorMvcAutoConfiguration.WhitelabelErrorViewConfiguration matched:
- @ConditionalOnProperty (server.error.whitelabel.enabled) matched (OnPropertyCondition)
- ErrorTemplate Missing did not find error template view (ErrorMvcAutoConfiguration.ErrorTemplateMissingCondition)
ErrorMvcAutoConfiguration.WhitelabelErrorViewConfiguration#beanNameViewResolver matched:
- @ConditionalOnMissingBean (types: org.springframework.web.servlet.view.BeanNameViewResolver; SearchStrategy: all) did not find any beans (OnBeanCondition)
ErrorMvcAutoConfiguration.WhitelabelErrorViewConfiguration#defaultErrorView matched:
- @ConditionalOnMissingBean (names: error; SearchStrategy: all) did not find any beans (OnBeanCondition)
以及还有这些
Exclusions:
-----------
None
Unconditional classes:
----------------------
org.springframework.boot.autoconfigure.context.ConfigurationPropertiesAutoConfiguration
org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration
org.springframework.boot.autoconfigure.info.ProjectInfoAutoConfiguration
一、首先说一下打印的CONDITIONS EVALUATION REPORT这些信息是什么,有什么用
需要说明的一点,这些并不是报错,即使打印他们项目照样可以启动运行。他们只是一些打印出来的项目的一些日志信息。如果你能读懂,利用得好,还会对你有帮助。
之所以去掉他们,是因为这些日志信息大多情况下用不到,启动时打印出来看起来烦人。
二、日志出现的原因
因为项目中配置了日志的等级,也即是level属性。所以才会导致他们的出现。
三、去除打印
去除很简单了,只需要在项目的配置文件中添加下面一句配置即可:
yml文件:
logging.level.org.springframework.boot.autoconfigure: error
properties文件:
logging.level.org.springframework.boot.autoconfigure=ERROR
一般配置了这句话就没有了,但是我却碰见了特殊情况,我在我的配置文件中配置了以后,日志信息还是会打印,让人头疼。最终发现:
如果你使用了配置中心来管理配置文件的时候,那么这句话就不能放在你的配置文件中了,而应该放在bootstartp.properties中,才会起作用。
logging.level.org.springframework.boot.autoconfigure=ERROR
#注册中心地址
#发布的时候需要改为线上的注册中心地址
#spring.cloud.nacos.config.server-addr=77.1.24.51:8848
spring.cloud.nacos.config.server-addr=127.0.0.1:8848
#发布的时候需要改为线上的名称空间
#spring.cloud.nacos.config.namespace=cqzz-prod
spring.cloud.nacos.config.namespace=cqzz-dev
#配置组名子,需要在nacos的配置设置,不然找不到
spring.cloud.nacos.config.group=netsafe
#配置后缀,properties不需要
spring.cloud.nacos.config.file-extension=yml
#加载顺序是【n】:n越大 越先加载 如果配置相同,后面加载的会覆盖前面加载的
#不再默认的组,手动启动自动刷新
spring.cloud.nacos.config.ext-config[1].data-id=service-**-main.yml
spring.cloud.nacos.config.ext-config[1].group=netsafe
spring.cloud.nacos.config.ext-config[1].refresh=true
# 不再默认的组,手动启动自动刷新
spring.cloud.nacos.config.ext-config[0].data-id=service-**-mp.yml
spring.cloud.nacos.config.ext-config[0].group=netsafe
spring.cloud.nacos.config.ext-config[0].refresh=true
ps:我的配置中心使用的是nacos,所以我项目中添加了bootstarp.properties文件
``

本文介绍了SpringBoot启动时打印大量CONDITIONS EVALUATION REPORT信息的含义及其作用,并分析了日志出现的原因,主要是由于配置了日志等级。解决方案是在配置文件中添加特定配置,通常在yml或properties文件中。但当使用Nacos等配置中心时,该配置应放入bootstarp.properties中才能生效。
2200

被折叠的 条评论
为什么被折叠?



