官网地址

程序猿升级课

热爱开源,喜欢摸索


SpringBoot配置多套环境

生产中会经历,开发,测试,到上线。三个阶段

 这个三个阶段,都有各自的配置文件,如果只是一个配置文件来回改
 会很容易出现错误的,那么springboot提供了很简答的解决办法

使用spring.profiles.active=test

  • 定义一个application.properties 里面写上

    • spring.profiles.active=test 默认启动test文件
  • 定义application-dev.properties

  • 定义application-test.properties

  • 定义application-prod.properties

使用java -jar mm.jar --spring.profiles.active=dev 运行启动dev环境

可以看到启动的是dev

2017-01-04 18:54:11.095  INFO 43026 --- [  restartedMain] dragonfly.DragonflyApplication           : Starting DragonflyApplication on KK-MINI.local with PID 43026 (/Users/liuxin/git/oto_saas_mybosc_pay/target/classes started by liuxin in /Users/liuxin/git/oto_saas_mybosc_pay)
2017-01-04 18:54:11.100  INFO 43026 --- [  restartedMain] dragonfly.DragonflyApplication           : The following profiles are active: dev
posted @ 2017-02-08 10:28  chinesszz  阅读(83)  评论(0编辑  收藏  举报
ヾ(≧O≦)〃嗷~