The Maven profile and the Spring profile are two completely different things. Your pom.xml defines
spring.profiles.active variable which is available in the build process, but not at runtime. That is why only the default profile is activated.
How to bind Maven profile with Spring?
You need to pass the build variable to your application so that it is available when it is started.
- Define a placeholder in your
@[email protected]variable must match the declared property from the Maven profile.
- Enable resource filtering in you pom.xml:
<build> <resources> <resource> <directory>src/main/resources</directory> <filtering>true</filtering> </resource> </resources> … </build>When the build is executed, all files in the
src/main/resourcesdirectory will be processed by Maven and the placeholder in your
application.propertieswill be replaced with the variable you defined in your Maven profile.
For more details you can go to my post where I described this use case.