spring boot 多環境(dev、test、prod)配置文件---命令行切換


  • properties配置格式
在Spring boot 中多環境配置文件名需要滿足application-{profile}.properties的格式,其中{profile}對於你的環境標識,比如:

 

在application.properties 中配置 spring.profiles.active=dev #默認開發環境

 

在啟動jar包時,使用命令行切換

  • java -jar xxx.jar --spring.profiles.active=test // 測試環境配置文件
    java -jar xxx.jar --spring.profiles.active=prod// 生產環境配置文件

     


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM