0

This was working for me and I'm not sure what changed.. I have my spring boot profile configured to be set based on a maven profile. The basics:

application.properties:

spring.profiles.active=@environment@

pom.xml:

    <profiles>
        <profile>
            <id>development</id>
            <activation>
                <activeByDefault>true</activeByDefault>
            </activation>
            <properties>
                <environment>development</environment>
            </properties>
            <dependencies>
                <dependency>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-devtools</artifactId>
                    <optional>true</optional>
                </dependency>
            </dependencies>
        </profile>
        <profile>
            <id>production</id>
            <properties>
                <environment>production</environment>
            </properties>
        </profile>
    </profiles>

When I run mvn clean package -Pdevelopment I see the line The following profiles are active: development.

Yet when I run mvn spring-boot:run -Pdevelopment I see the line The following profiles are active: @environment@.

Using the spring-boot:run command seems to not be able to resolve application property variables based on maven environment variables. Anyone know why? I tried adjusting the spring starter version without success.

Galen Howlett
  • 530
  • 4
  • 12

2 Answers2

1

According to the docs, you could tune the profiles to enable when running the application as follows:

$ mvn spring-boot:run -Dspring-boot.run.profiles=development

If not, try to comment your "spring.profiles.active" property in application.properties, that should work!

See also this thread.

marc13
  • 11
  • 2
  • Thanks, this does properly set the spring profile but then I lose the maven profile functionality by bypassing it. I did dig a little longer into those docs and found the flag that was overriding the default property expansion behavior. – Galen Howlett Jun 07 '21 at 22:15
0

Based on this tip in the docs, I added a configuration to my spring-boot-maven-plugin which broke this functionality:

<plugin>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-maven-plugin</artifactId>
    <configuration>
        <addResources>true</addResources>
    </configuration>
</plugin>

Removing the addResources configuration restores the property expansion behavior.

Galen Howlett
  • 530
  • 4
  • 12