Setting active profile and config location from command line in spring boot

后端 未结 11 1586
借酒劲吻你
借酒劲吻你 2020-11-27 09:33

I have a spring boot application.

I have three profiles in my application-> development, staging and production. So I have 3 files

  1. ap
11条回答
  •  执笔经年
    2020-11-27 10:13

    I had to add this:

    bootRun {
        String activeProfile =  System.properties['spring.profiles.active']
        String confLoc = System.properties['spring.config.location']
        systemProperty "spring.profiles.active", activeProfile
        systemProperty "spring.config.location", "file:$confLoc"
    }
    

    And now bootRun picks up the profile and config locations.

    Thanks a lot @jst for the pointer.

提交回复
热议问题