Wednesday, October 30, 2019

Spring Boot: Importance of @AutoConfiguration


Everyone must have seen magic of spring boot, where it auto adds all the necessary dependencies based on presence of jar, property etc...

Behind the scene the magic is done by @AutoConfiguration annotation.

Instead of saying the magic is done by @Autoconfiguration, I would say actual work is done by @Conditional annotations.

@Conditional annotation allows us to configure beans based on anything like classType, jar, value of property param etc...

I would suggest you guys to read about @Conditional very well, the all magic is done by this annotation only. @AutoConfiguration is just a wrapper.



If you need to find out what auto-configuration is currently being applied, and why, start your application with the --debug switch. Doing so enables debug logs for a selection of core loggers and logs a conditions report to the console.

No comments: