Developing Java Applications with Spring and Spring Boot
by Claudio Eduardo de Oliveira, Greg L. Turnquist, Alex Antonov
How it works...
As we learned from the previous recipe, Spring Boot will automatically process all the configuration class entries from spring.factories during the application context creation. Without any extra guidance, everything that is annotated with an @Bean annotation will be used to create a Spring Bean. This functionality is actually a part of the plain old Spring Framework Java Configuration. What Spring Boot adds on top is the ability to conditionally control the rules for when certain @Configuration or @Bean annotations should be executed and when it is best to ignore them.
In our case, we used the @ConditionalOnMissingBean annotation to instruct Spring Boot to create our DbCountRunner bean only if there was no other bean matching ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access