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 ...

Get Spring Boot 2.0 Cookbook - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.