In Spring we use the @EnableAutoConfiguration each time when we use the @SpringBootApplication annotation. If we look at the @SpringBootApplication we can see that this automatically enables the @EnableAutoConfiguration. This last mentioned annotation triggers all the auto-configuration enabled configurations on the classpath. We can write an auto-configuration enabled @Configuration ourself in only two steps.

package com.jdriven.example;

import org.springframework.context.annotation.Configuration;

public class MyOwnAutoConfiguration {

    //You can define your own beans here and
    //further setup this Configuration as you normally would do


In **/src/main/resources/META-INF/** create a file called **spring.factories** and add the following snippet to the file.


If you wrap this all in a JAR and add this as a classpath dependency to another Spring Application, the above MyOwnAutoConfiguration is triggered. Happy developing!