How to set the Profile using application.properties in Spring?

后端 未结 3 435
借酒劲吻你
借酒劲吻你 2020-12-18 06:35

I would like to set the Profile using application.properties file with the entry:

mode=master

How to set spring.profiles.active in my conte

3条回答
  •  不知归路
    2020-12-18 06:38

    You can use either a environment variable, system variable (-D option for the JVM or application) or put it in JNDI (java:comp/env/. You cannot however put it in a properties file, as it is needed before the that specific properties file is read.

    There is more information in the @Profile javadocs.

    Another solution is to create your own ApplicationContextInitializer implementation which reads a certain file and activates the given profile.

提交回复
热议问题