2 files properties in Spring Boot [closed]

1

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?

    
asked by anonymous 10.10.2017 / 18:47

1 answer

1

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:

pom.xml

application.properties

    
10.10.2017 / 19:02