This post demonstrates how to use the @Conditional annotation which is the workhorse of Spring Boot’s automatic configuration. You may also use this technique in your own codes.
Using @Conditional with @Configuration in Spring
Using @Conditional with @Configuration in Spring allows us to group @Bean objects loaded on a specific condition without resorting to using @Profile and too many @Bean/@Conditional. Requirements We used the following items for this post. Spring Boot 2.0.4.RELEASE JDK 8