I need to activate profiles based on environment specifics in Spring Boot Maven application. I configured profiles in settings.xml
<profiles>
<profile>
<id>dev</id>
<activation>
<activeByDefault>false</activeByDefault> </activation>
<repositories>
<repository>
<id>devRepo</id>
<url>https://customRepo/maven/v1</url>
<releases>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</snapshots>
</repository>
</repositories>
</profile>
<profile>
<id>qa</id>
<activation>
<activeByDefault>false</activeByDefault> </activation>
<repositories>
<repository>
<id>qaRepo</id>
<url>https://customRepo2/maven/v1</url>
<releases>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</snapshots>
</repository>
</repositories>
</profile>
</profiles>
I tried by activating the profiles using commands -Pdev
mvn spring-boot:run -s settings.xml -D"spring-boot.run.profiles"=dev help:active-profiles
But profiles are not activated properly. But It's working by adding activeprofiles
tags.
<activeProfiles>
<activeProfile>dev</activeProfile>
</activeProfiles>
But I need to activate the profiles environment specific like
<activeProfiles>
<activeProfile>$env</activeProfile>
</activeProfiles>
Any way we can pass arguments to activeProfile
in settings.xml file? Similar like this -Denv
Reference:
Maven: How do I activate a profile from command line?
Configure active profile in SpringBoot via Maven