Load environment-specific properties for use with PropertyPlaceholderConfigurer?

后端 未结 8 1233
夕颜
夕颜 2020-12-23 17:24

This seems like a pretty common problem, but I haven\'t found any sort of consensus on the best method, so I\'m posing the question here.

I\'m working on a command-l

8条回答
  •  忘掉有多难
    2020-12-23 17:43

    Hi after reading Spring in Action found a solution provided by Spring. Profile Or Conditional : you can create multiple profile eg. test, dev, prod etc.

    Spring honors two separate properties when determining which profiles are active: spring.profiles.active and spring.profiles.default . If spring.profiles.active is set, then its value determines which profiles are active. But if spring .profiles.active isn’t set, then Spring looks to spring.profiles.default . If neither spring.profiles.active nor spring.profiles.default is set, then there are no active profiles, and only those beans that aren’t defined as being in a profile are created.

    There are several ways to set these properties: 1 As initialization parameters on DispatcherServlet 2 As context parameters of a web application 3 As JNDI entries 4 As environment variables 5 As JVM system properties 6 Using the @ActiveProfiles annotation on an integration test class

提交回复
热议问题