Over a million developers have joined DZone.

Report Applied Auto-configuration Spring Boot

A tutorial on how to use the auto-configuration feature in Spring Boot and Gradle.

· DevOps Zone

Discover how to optimize your DevOps workflows with our cloud-based automated testing infrastructure, brought to you in partnership with Sauce Labs

The auto-configuration feature in Spring Boot adds beans to our application context based on conditions. For example based on the availability of a class on the class path or a environment property beans are enabled or disabled. We must apply the @EnableAutoConfiguration or @SpringBootApplicaiton in our Spring Boot application to make this work. To get an overview of all the configurations that had positive and negative conditional matches in our application we can use the --debug command-line option. This will print out a report to System.out with a complete overview. We can check why a configuration is applied or not.

In the following Gradle build file we add the option --debug to the args property of the bootRun task:

buildscript {
    ext {
        springBootVersion = '1.2.5.RELEASE'
    repositories {
    dependencies {

apply plugin: 'groovy'
apply plugin: 'spring-boot' 

sourceCompatibility = 1.8
targetCompatibility = 1.8

repositories {

dependencies {
    compile 'org.codehaus.groovy:groovy-all:2.4.4'
    compile "org.springframework.boot:spring-boot-starter-actuator"
    compile "org.springframework.boot:spring-boot-starter-groovy-templates"
    compile "org.springframework.boot:spring-boot-starter-web"
    runtime "com.h2database:h2"
    testCompile "org.springframework.boot:spring-boot-starter-test"

bootRun {
    // Use --debug option to print out 
    // auto-configuration report.
    args '--debug'

Let's run the bootRun task and check the output (lines are omitted in the output shown next):

Download “The DevOps Journey - From Waterfall to Continuous Delivery” to learn learn about the importance of integrating automated testing into the DevOps workflow, brought to you in partnership with Sauce Labs.

devops,gradle,spring boot,java

Published at DZone with permission of Hubert Klein Ikkink, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

The best of DZone straight to your inbox.

Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}