美文网首页Spring Boot实践记录
SpringBoot配置多套环境

SpringBoot配置多套环境

作者: Chinesszz | 来源:发表于2017-02-08 10:27 被阅读237次

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

     这个三个阶段,都有各自的配置文件,如果只是一个配置文件来回改
     会很容易出现错误的,那么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
    

    相关文章

      网友评论

        本文标题:SpringBoot配置多套环境

        本文链接:https://www.haomeiwen.com/subject/eysvittx.html