0

In Spring 3.2 by default, Spring Environment object will resolve spring.profiles.active OS environment or -D JVM switch. I have a use case where I need to set the active profile from a common properties file. However, I am unable to make Environment resolve the active profile correctly.

Is there away to do that without using property placeholder?

Hector
  • 11
  • 3
  • 1
    No nor will a a `property-placeholder` work as the profiles are determined before that. You could create an `ApplicationContextInitializer` which reads your file and enabled the profiles before the context is actually loaded. – M. Deinum Jan 20 '15 at 14:39
  • Is there a reason you can't just use your 'common' properties file as the Spring boot properties? i.e. `--spring.config.location=file:/my/config.properties` – Steve Jan 20 '15 at 14:47
  • thanks Steve - are you referring to Spring boot here? – Hector Jan 20 '15 at 16:06

1 Answers1

0

Check this option for setting the active profile from a properties file, and this one for reading from a VM parameter.

Community
  • 1
  • 1
gabrielgiussi
  • 9,245
  • 7
  • 41
  • 71