springboot read pom configuration

I was in the maven pom file in a multi-environment variable configuration, quotes maven-resources-plugin, specify the configuration file under different circumstances in application.properties by the following configuration file,

spring.profiles.active = ${profiles.active}

However, $ {profiles.active} variable value can not be obtained from alternative pom file. It is a problem for a long time, finally found the root of the problem in the original bloggers article.

The original blogger quoted saying:

Because of ${}the way will be processed maven. If you pom inherited spring-boot-starter-parent, the Spring
the Boot has maven-resources-plugins default ${}mode to a @@mode, such as@name@

If you want to continue using $ {} placeholder embodiment, only need to add the following configuration file in pom:

<build>
    <pluginManagement>
        <plugins>
            <plugin>
                <artifactId>maven-resources-plugin</artifactId>
                <configuration>
                    <encoding>utf-8</encoding>
                    <useDefaultDelimiters>true</useDefaultDelimiters>
                </configuration>
            </plugin>
        </plugins>
    </pluginManagement>
</build>
  
  
Published 18 original articles · won praise 5 · Views 6723

Guess you like

Origin blog.csdn.net/qq_28687183/article/details/90199910