Add in pom:
<build>
...
<resources>
<resource>
<directory>src/main/resources< /directory>
<filtering>true</filtering>
</resource>
</resources>
...
</build>
-
Add
<plugin>
<groupId>org.apache.maven. plugins</groupId>
<artifactId>maven-help-plugin< /artifactId>
<version>3.2.0</version>
<executions>
<execution>
<id>show-profiles</id>
<phase>compile</phase>
<goals>
<goal>active-profiles</goal>
</goals>
</execution>
</executions>
</plugin>
-
Add
<profiles>
<profile>
<id>dev</id>
<properties>
<activatedProperties>dev</ activatedProperties>
</properties>
<activation>
<activeByDefault>true</ activeByDefault>
</activation>
</profile>
<profile>
<id>prod</id>
<properties>
<activatedProperties>prod</ activatedProperties>
</properties>
</profile>
</profiles>
-
Create application.properties:
spring.profiles.active=@ activatedProperties@
-
Create:
application-dev.properties
application-prod.properties
-
run:
mvn clean spring-boot:run -Pprod
//or
mvn clean spring-boot:run -Dspring-boot.run.profiles=dev