spring-boot:run啟動時,如何帶設置環境參數dev,test.


這邊在linux 啟動springboot的jar包時候,多次報錯 最終使用

java -jar -Dspring.profiles.active=test demo-0.0.1-SNAPSHOT.jar的方式成功

 

Maven啟動指定Profile通過-P,如mvn spring-boot:run -Ptest,但這是Maven的Profile。

如果要指定spring-boot的spring.profiles.active,spring-boot 1.x 使用mvn spring-boot:run -Drun.profiles=test,spring-boot 2.x 使用mvn spring-boot:run -Dspring-boot.run.profiles=test。參考資料:https://docs.spring.io/spring-boot/docs/2.0.1.RELEASE/maven-plugin/examples/run-profiles.html

如果使用命令行直接運行jar文件,則使用java -jar -Dspring.profiles.active=test demo-0.0.1-SNAPSHOT.jar

如果使用開發工具,運行Application.java文件啟動

則增加參數--spring.profiles.active=test


免責聲明!

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



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