springboot配置之在配置文件中配置debug=true 开启自动配置类报告

在这里插入图片描述
启动项目,观察控制台:
在这里插入图片描述
将控制台的自动配置类报告随意的抽取出来一些:

============================
CONDITIONS EVALUATION REPORT   自动配置类报告
============================


Positive matches:   生效的自动配置类
-----------------

   CacheAutoConfiguration matched:  匹配到了CacheAutoConfiguration 对象
      - @ConditionalOnClass found required class 'org.springframework.cache.CacheManager' (OnClassCondition)
      - @ConditionalOnBean (types: org.springframework.cache.interceptor.CacheAspectSupport; SearchStrategy: all) found bean 'cacheInterceptor'; @ConditionalOnMissingBean (names: cacheResolver; types: org.springframework.cache.CacheManager; SearchStrategy: all) did not find any beans (OnBeanCondition)

   CacheAutoConfiguration#cacheManagerCustomizers matched:  匹配到了CacheAutoConfiguration对象
      - @ConditionalOnMissingBean (types: org.springframework.boot.autoconfigure.cache.CacheManagerCustomizers; SearchStrategy: all) did not find any beans (OnBeanCondition)

   CodecsAutoConfiguration matched:   匹配到了CodecsAutoConfiguration 对象
      - @ConditionalOnClass found required class 'org.springframework.http.codec.CodecConfigurer' (OnClassCondition)

   CodecsAutoConfiguration.JacksonCodecConfiguration matched:    匹配到了JacksonCodecConfiguration 对象
      - @ConditionalOnClass found required class 'com.fasterxml.jackson.databind.ObjectMapper' (OnClassCondition)

   CodecsAutoConfiguration.JacksonCodecConfiguration#jacksonCodecCustomizer matched:   匹配到了JacksonCodecConfiguration对象
      - @ConditionalOnBean (types: com.fasterxml.jackson.databind.ObjectMapper; SearchStrategy: all) found bean 'jacksonObjectMapper' (OnBeanCondition)

Negative matches:   未生效的自动配置类
-----------------

   RedisAutoConfiguration:
      Did not match:  没有匹配
         - @ConditionalOnClass did not find required class 'org.springframework.data.redis.core.RedisOperations' (OnClassCondition)

   RedisCacheConfiguration:
      Did not match: 没有匹配
         - @ConditionalOnClass did not find required class 'org.springframework.data.redis.connection.RedisConnectionFactory' (OnClassCondition)

   RedisReactiveAutoConfiguration:
      Did not match: 没有匹配
         - @ConditionalOnClass did not find required class 'reactor.core.publisher.Flux' (OnClassCondition)

   RedisRepositoriesAutoConfiguration:
      Did not match: 没有匹配
         - @ConditionalOnClass did not find required class 'org.springframework.data.redis.repository.configuration.EnableRedisRepositories' (OnClassCondition)

Positive matches: 生效的自动配置类
Negative matches: 未生效的自动配置类
******** matched: 匹配到了对象(配置加载了对象,容器当中存在此对象)
Did not match: 没有匹配(没有配置加载此对象,容器当中不存在此对象)
所以 我们可以从此处看出项目启动的时候,springboot配置的哪些生效自动配置类

  • 2
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
好的,您想了解关于在Spring Boot如何配置外置的Log4j2日志记录器是吗?首先,您需要在您的Maven或Gradle构建文件添加Log4j2的依赖项,并将配置文件(例如log4j2.xml或log4j2.properties)放置在您选择的位置(例如,您可以将其放置在项目根目录的config文件夹)。然后,您需要在Spring Boot应用程序的Startup添加以下代码以使Log4j2配置生效: ```java import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.context.event.ApplicationReadyEvent; import org.springframework.context.event.EventListener; import org.springframework.core.io.Resource; import org.springframework.core.io.support.PathMatchingResourcePatternResolver; import org.springframework.core.io.support.ResourcePatternResolver; import org.springframework.util.Assert; @SpringBootApplication public class Application { @EventListener public void handleApplicationReadyEvent(ApplicationReadyEvent event) { ResourcePatternResolver resolver = new PathMatchingResourcePatternResolver(); Resource[] resources = resolver.getResources("classpath*:log4j2.xml"); Assert.isTrue(resources.length == 1, "log4j2.xml file must be present in the classpath"); System.setProperty("log4j.configurationFile", resources[0].getURI().toString()); } public static void main(String[] args) { SpringApplication.run(Application.class, args); } } ``` 这段代码将在应用程序启动时加载log4j2.xml配置文件,并将其设置为系统属性“log4j.configurationFile”。设置后,Log4j2将自动使用该文件配置应用程序的日志记录。此外,请确保在您的应用程序使用了log4j2的日志记录API,例如通过以下方式: ```java import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class MyExampleClass { private static final Logger logger = LoggerFactory.getLogger(MyExampleClass.class); public void doSomething() { logger.debug("Hello world!"); } } ``` 希望这可以回答您的问题!

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值