關於在springboot中使用maven的profile打包,無法替換application.properties中 ${} 佔位符的問題

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

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章