Spring Boot Profiles
In this tutorial, we will deep dive into the features that spring profile going to offer
Any @Component or @Configuration can be marked with @Profile. spring.profiles.active property is used to define your active profile. This can be mentioned either in the configuration file(application.properties or application.yml) or through program arguments. If an active profile is specified through program arguments it will replace the profile defined in configuration file. Sometimes it is useful to have profile-specific properties that add to the active profiles rather than replace them. The spring.profiles.include property can be used to unconditionally add active profiles.
You can also programmatically set your profiles using SpringApplication#setAdditionalProfiles().
Profile-specific variants of configurations can also be defined. For example for "development" profile application-development.properties file is read and for "production" profile application-production.properties file is read.
Spring Profiles:
Spring profiles help you to conditionally select various beans and configuration that should be included into the project. This will be very helpful if you work with multiple environments and configurations.Any @Component or @Configuration can be marked with @Profile. spring.profiles.active property is used to define your active profile. This can be mentioned either in the configuration file(application.properties or application.yml) or through program arguments. If an active profile is specified through program arguments it will replace the profile defined in configuration file. Sometimes it is useful to have profile-specific properties that add to the active profiles rather than replace them. The spring.profiles.include property can be used to unconditionally add active profiles.
You can also programmatically set your profiles using SpringApplication#setAdditionalProfiles().
Profile-specific variants of configurations can also be defined. For example for "development" profile application-development.properties file is read and for "production" profile application-production.properties file is read.
Comments
Post a Comment