spring-boot:run启动时,如何带设置环境参数dev,test.

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_31840023/article/details/82662819

这边在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

猜你喜欢

转载自blog.csdn.net/qq_31840023/article/details/82662819