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
如果使用開發(fā)工具域蜗,運行Application.java文件啟動巨双,
則增加參數(shù)--spring.profiles.active=test