转自:https://www.jianshu.com/p/929b9aa70dc8
最近在项目中使用springboot时发现,采用在pom中定义不同的profile,并且maven打包时
采用-P参数并不能替换我application.properties文件中指定占位符的问题。
原因是:发现最终是因为springboot导致的,查看其pom继承。
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.2.RELEASE</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
查看spring-boot-starter-parent-2.1.2.RELEASE.pom
解决方案:
将application.properties中的占位符由${key} -> @key@
方案2 请参考参考链接