Spring Boot Autoconfiguration demistified

Photo by James Harrison on Unsplash

Hi random reader.

“Spring Boot’s @EnableAutoconfiguration - This humble little annotation might as well be named @Abdracadabra because it’s one line of configuration that enables the magic of Spring Boot auto-configuration. This one line keeps you from having to write the pages of configuration that would be required otherwise.”

So what is this “Autoconfiguration” all about?

“What if for each and every dependency “X”, that might be applicable to the pattern of configuration above, we create a new seperate ‘Parent’ dependency which we call “X-Starter” and which will have a transitive dependency on “X” itself and all other needed configuration jars. And lastly, it will also have configuration code snippets, with @Configuration and @Bean annotations in them.

For any arbitrary user of our X-Starter library, simply addition of X-Starter as a dependency of a project is needed to have fully ready to use and fully configured spring beans. Since, as you already guessed, X-Starter will pull all the transitive dependencies and the result is that the user of our new dependency will not have to write all the boiler plate code of configurations themselves.”

Software engineer. Clean code enthusiast.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store