Skip to content

자동 구성 분석 방법

1. -Ddebug, --debug

images/how-to-analysis-1.png

디버그 옵션 추가 후 StartUp 로그
============================
CONDITIONS EVALUATION REPORT
============================


Positive matches:
-----------------

   AopAutoConfiguration matched:
      - @ConditionalOnProperty (spring.aop.auto=true) matched (OnPropertyCondition)

   AopAutoConfiguration.ClassProxyingConfiguration matched:
      - @ConditionalOnMissingClass did not find unwanted class 'org.aspectj.weaver.Advice' (OnClassCondition)
      - @ConditionalOnProperty (spring.aop.proxy-target-class=true) matched (OnPropertyCondition)

...



Negative matches:
-----------------

   AopAutoConfiguration.AspectJAutoProxyingConfiguration:
      Did not match:
         - @ConditionalOnClass did not find required class 'org.aspectj.weaver.Advice' (OnClassCondition)

   ArtemisAutoConfiguration:
      Did not match:
         - @ConditionalOnClass did not find required class 'jakarta.jms.ConnectionFactory' (OnClassCondition)

...

2. ConditionEvaluationReport

ConditionalEvaluationReport 를 주입 받아 직접 원하는 형태로 출력하는 ApplicationRunner 빈을 하나 등록 한다.

@Bean  
fun run(report: ConditionEvaluationReport) = ApplicationRunner {  
    val count = report.conditionAndOutcomesBySource.entries  
        .filter { condition -> condition.value.isFullMatch }  
        .filter { condition -> !condition.key.contains("Jmx") }  
        .map { condition ->  
            println(condition.key)  
            condition.value.forEach { println("\t${it.outcome}") }  
            println()  
            condition  
        }  
        .count()  
    println("자동 등록된 빈은 총 $count 개!")  
}

implementation("org.springframework.boot:spring-boot-starter") 만 추가했을때 등록되는 자동 목록

2023-02-03T16:46:04.003+09:00  INFO 9149 --- [           main] com.example.demo.DemoApplicationKt       : Started DemoApplicationKt in 0.563 seconds (process running for 0.717)
org.springframework.boot.autoconfigure.aop.AopAutoConfiguration
    @ConditionalOnProperty (spring.aop.auto=true) matched

org.springframework.boot.autoconfigure.aop.AopAutoConfiguration$ClassProxyingConfiguration
    @ConditionalOnMissingClass did not find unwanted class 'org.aspectj.weaver.Advice'
    @ConditionalOnProperty (spring.aop.proxy-target-class=true) matched

org.springframework.boot.autoconfigure.cache.GenericCacheConfiguration
    Cache org.springframework.boot.autoconfigure.cache.GenericCacheConfiguration automatic cache type

org.springframework.boot.autoconfigure.cache.NoOpCacheConfiguration
    Cache org.springframework.boot.autoconfigure.cache.NoOpCacheConfiguration automatic cache type

org.springframework.boot.autoconfigure.cache.SimpleCacheConfiguration
    Cache org.springframework.boot.autoconfigure.cache.SimpleCacheConfiguration automatic cache type

org.springframework.boot.autoconfigure.context.LifecycleAutoConfiguration#defaultLifecycleProcessor
    @ConditionalOnMissingBean (names: lifecycleProcessor; SearchStrategy: current) did not find any beans

org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration#propertySourcesPlaceholderConfigurer
    @ConditionalOnMissingBean (types: org.springframework.context.support.PropertySourcesPlaceholderConfigurer; SearchStrategy: current) did not find any beans

org.springframework.boot.autoconfigure.sql.init.SqlInitializationAutoConfiguration
    @ConditionalOnProperty (spring.sql.init.enabled) matched
    NoneNestedConditions 0 matched 1 did not; NestedCondition on SqlInitializationAutoConfiguration.SqlInitializationModeCondition.ModeIsNever @ConditionalOnProperty (spring.sql.init.mode=never) did not find property 'mode'

org.springframework.boot.autoconfigure.task.TaskExecutionAutoConfiguration
    @ConditionalOnClass found required class 'org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor'

org.springframework.boot.autoconfigure.task.TaskExecutionAutoConfiguration#applicationTaskExecutor
    @ConditionalOnMissingBean (types: java.util.concurrent.Executor; SearchStrategy: all) did not find any beans

org.springframework.boot.autoconfigure.task.TaskExecutionAutoConfiguration#taskExecutorBuilder
    @ConditionalOnMissingBean (types: org.springframework.boot.task.TaskExecutorBuilder; SearchStrategy: all) did not find any beans

org.springframework.boot.autoconfigure.task.TaskSchedulingAutoConfiguration
    @ConditionalOnClass found required class 'org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler'

org.springframework.boot.autoconfigure.task.TaskSchedulingAutoConfiguration#taskSchedulerBuilder
    @ConditionalOnMissingBean (types: org.springframework.boot.task.TaskSchedulerBuilder; SearchStrategy: all) did not find any beans

자동 등록된 빈은 총 13 개!

3. SpringBoot Reference

images/how-to-analysis.png


Last update: February 26, 2023
Created: February 3, 2023