I'm developing an API with Spring Boot, and I have 2 properties files for the development and production environments, how do I set the properties file for a particular environment?
I'm developing an API with Spring Boot, and I have 2 properties files for the development and production environments, how do I set the properties file for a particular environment?
Add profiles and prod in your pom.xml / strong>
<profiles>
<profile>
<id>dev</id>
<properties>
<spring.profile>dev</spring.profile>
</properties>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
</profile>
<profile>
<id>prod</id>
<properties>
<spring.profile>prod</spring.profile>
</properties>
</profile>
</profiles>
2. Add the following line to your application.properties file:
[email protected]@
3. Create two files that represent your dev and prod
application-dev.properties
application-prod.properties
4. Run the project according to the profile
dev: mvn clean compile spring-boot:run
prod: mvn clean compile spring-boot:run -Pprod
In my GitHub you have a project with this configuration. Links: