Display Auto-Configuration Report in Spring Boot

1. Overview

The auto-configuration mechanism in Spring Boot attempts to automatically configure an application based on its dependencies.

In this quick tutorial, we’ll see how Spring Boot can log its auto-configuration report at startup time.

2. Sample Application

Let’s write a simple Spring Boot application that we’ll use in our examples:

@SpringBootApplication
public class App {
    public static void main(String[] args) {
        SpringApplication.run(App.class, args);
    }
}

3. Application Properties Approach

In starting up this application, we don’t get a lot of information about how or why Spring Boot decided to compose our application’s configuration.

But, we can have Spring Boot create a report simply by enabling debug mode in our application.properties file:

debug=true

Or our application.yml file:

debug: true

4. Command-Line Approach

Or, if we don’t want to use the properties file approach, we can trigger the auto-configuration report by starting the application with the –debug switch:

$ java -jar myproject-0.0.1-SNAPSHOT.jar --debug

5. Report Output

The auto-configuration report contains information about the classes that Spring Boot found on the classpath and configured automatically. It also shows information about classes that are known to Spring Boot but were not found on the classpath.

And, because we’ve set debug=true, then we see it in our output:

============================
CONDITIONS EVALUATION REPORT
============================


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

   AopAutoConfiguration matched:
      - @ConditionalOnClass found required classes 'org.springframework.context.annotation.EnableAspectJAutoProxy', 
        'org.aspectj.lang.annotation.Aspect', 'org.aspectj.lang.reflect.Advice', 'org.aspectj.weaver.AnnotatedElement'; 
        @ConditionalOnMissingClass did not find unwanted class (OnClassCondition)
      - @ConditionalOnProperty (spring.aop.auto=true) matched (OnPropertyCondition)

   AopAutoConfiguration.CglibAutoProxyConfiguration matched:
      - @ConditionalOnProperty (spring.aop.proxy-target-class=true) matched (OnPropertyCondition)

   AuditAutoConfiguration#auditListener matched:
      - @ConditionalOnMissingBean (types: org.springframework.boot.actuate.audit.listener.AbstractAuditListener; 
        SearchStrategy: all) did not find any beans (OnBeanCondition)

   AuditAutoConfiguration.AuditEventRepositoryConfiguration matched:
      - @ConditionalOnMissingBean (types: org.springframework.boot.actuate.audit.AuditEventRepository; 
        SearchStrategy: all) did not find any beans (OnBeanCondition)

   AuditEventsEndpointAutoConfiguration#auditEventsEndpoint matched:
      - @ConditionalOnBean (types: org.springframework.boot.actuate.audit.AuditEventRepository; 
        SearchStrategy: all) found bean 'auditEventRepository'; 
        @ConditionalOnMissingBean (types: org.springframework.boot.actuate.audit.AuditEventsEndpoint; 
        SearchStrategy: all) did not find any beans (OnBeanCondition)
      - @ConditionalOnEnabledEndpoint no property management.endpoint.auditevents.enabled found 
        so using endpoint default (OnEnabledEndpointCondition)


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

   ActiveMQAutoConfiguration:
      Did not match:
         - @ConditionalOnClass did not find required classes 'javax.jms.ConnectionFactory', 
           'org.apache.activemq.ActiveMQConnectionFactory' (OnClassCondition)

   AopAutoConfiguration.JdkDynamicAutoProxyConfiguration:
      Did not match:
         - @ConditionalOnProperty (spring.aop.proxy-target-class=false) did not find property 
           'proxy-target-class' (OnPropertyCondition)

   ArtemisAutoConfiguration:
      Did not match:
         - @ConditionalOnClass did not find required classes 'javax.jms.ConnectionFactory', 
           'org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory' (OnClassCondition)

   AtlasMetricsExportAutoConfiguration:
      Did not match:
         - @ConditionalOnClass did not find required class 'io.micrometer.atlas.AtlasMeterRegistry' 
           (OnClassCondition)

   AtomikosJtaConfiguration:
      Did not match:
         - @ConditionalOnClass did not find required class 'com.atomikos.icatch.jta.UserTransactionManager' 
           (OnClassCondition)

6. Conclusion

In this quick tutorial, we saw how to display and read a Spring Boot auto-configuration report.

And as always, the source code for the above example can be found over on GitHub.

Related posts:

Java Program to Implement Gale Shapley Algorithm
Java Program to Implement Lloyd’s Algorithm
Introduction to Java 8 Streams
Java Program to Implement the Alexander Bogomolny’s UnOrdered Permutation Algorithm for Elements Fro...
Running Spring Boot Applications With Minikube
Java Program to Implement the Program Used in grep/egrep/fgrep
Java Program to do a Depth First Search/Traversal on a graph non-recursively
A Quick Guide to Using Keycloak with Spring Boot
Converting a List to String in Java
Java Program to Perform Inorder Non-Recursive Traversal of a Given Binary Tree
Java Program to Find ith Largest Number from a Given List Using Order-Statistic Algorithm
Spring Boot Security Auto-Configuration
Difference Between Wait and Sleep in Java
List Interface trong Java
Implementing a Binary Tree in Java
Java Program to Test Using DFS Whether a Directed Graph is Weakly Connected or Not
Java Program to Implement Randomized Binary Search Tree
Java Program to implement Dynamic Array
Java Program to Implement Maximum Length Chain of Pairs
Introduction to Java Serialization
Java Program to Implement Dijkstra’s Algorithm using Queue
Hướng dẫn Java Design Pattern – Prototype
Java Program to Implement Euler Circuit Problem
Java Program to Find Whether a Path Exists Between 2 Given Nodes
How to Round a Number to N Decimal Places in Java
Guide to the Fork/Join Framework in Java
Spring 5 WebClient
Bootstrapping Hibernate 5 with Spring
Java Program to Implement Horner Algorithm
Java Program to Implement the MD5 Algorithm
Java Program to Generate All Subsets of a Given Set in the Lexico Graphic Order
Hướng dẫn Java Design Pattern – Facade