springboot无法完成变量从pom到.properties文件自动替换的问题

来源:互联网 发布:ubuntu 16.04 jenkins 编辑:程序博客网 时间:2024/05/22 07:41

原贴地址:http://www.cnblogs.com/softidea/p/5644755.html

我在maven的pom文件中进行了多环境变量配置,引用了maven-resources-plugin,在application.properties文件中通过以下配置指定不同环境下的配置文件,

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

但是${profiles.active}无法从pom文件中获取变量值替换。这个问题困扰了很久,终于在原博主的文章中发现了问题的根源。

引用原博主的一句话:

由于${}方式会被maven处理。如果你pom继承了spring-boot-starter-parent,Spring
Boot已经将maven-resources-plugins默认的${}方式改为了@@方式,如@name@

如果还想继续使用${}占位符方式,只需要在pom文件中加上下面配置即可:

<build>    <pluginManagement>        <plugins>            <plugin>                <artifactId>maven-resources-plugin</artifactId>                <configuration>                    <encoding>utf-8</encoding>                    <useDefaultDelimiters>true</useDefaultDelimiters>                </configuration>            </plugin>        </plugins>    </pluginManagement></build>
阅读全文
0 0
原创粉丝点击