配置方法
在 Maven pom.xml 文件 properties 中加入:
<resource.delimiter>${}</resource.delimiter>
然后在 Maven pom.xml 文件 build-resources 中加入:
<resource>
<directory>${project.basedir}/src/main/resources</directory>
<filtering>true</filtering>
<includes>
<include>**/*.properties
</include> <!-- 你要替换的 properties 文件,如 application.properties、application-dev.properties,我的是匹配所有 .properties 扩展结尾的文件 -->
</includes>
</resource>
项目 src/main/resources 下的 application.properties 文件属性配置中包含一项 Maven pom.xml 的属性值:
最后打包看效果:
maven clean package
值替换成功,问题解决。
《“Spring Boot 2.x properties 配置文件中引用 Maven pom.xml 中的属性值”》 有 1 条评论
👏👏👏鼓掌