Developing Java Applications with Spring and Spring Boot
by Claudio Eduardo de Oliveira, Greg L. Turnquist, Alex Antonov
How it works...
In this recipe, we experimented with using profiles and applying additional configuration settings based on the active profiles. Profiles were first introduced in Spring Framework 3.2 and were used to conditionally configure the beans in context, depending on which profiles were active. In Spring Boot, this facility was extended even further to allow configuration separation as well.
By placing an @Profile("logger") annotation on our StartupRunner@Bean creation method, Spring will be instructed to create the bean only if the logger profile has been activated. Conventionally, this is done by passing the --spring.profiles.active option in the command line during the application startup. In the tests, another way that this can ...
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