轉自: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 請參考參考鏈接