Tips && Tricks

Maven and Spring Boot Profiles

27 Jun 2016

It is often very convinient if we could adjust the spring boot profiles from an external tool like maven. This might come handy when we want to easily activate profiles during the maven build without the need for editing the boot properties file manually.

Bellow code snippets does exactly the same and can be used to control spring boot profiles using the active maven profile.

Step 1 - Define profiles in pom.xml

While the profiles are defined, we also create a new property named Later we will use this maven variable/property value to activate spring profile.


Step 2 - Make maven properties available in resources

This helps to use the above defined maven property directly in the spring boot properties file


Step3 - Set the spring-boot active profile

Spring boot uses the property to set the active profile. We will now set the active profile based on the value we set in the maven property before. The syntax is of the format

comments powered by Disqus