0

As per my understanding, the @Profile annotation looks for the value of spring.profiles.active system property. Can we map @Profile with the custom profile resource so that instead of using the value of spring.profiles.active, it uses the value of env for some of the classes.

I have seen one of the annotation @IfProfileValue(name = "env", values = { "dev", "qa", "uat" }), which i thought, would work for me, because in this case name provides the profile resource and the env should be set as system property (e.g; -denv=qa). But this seems to be working only with test classes

Any solution for the problem?

Tarun Gupta
  • 107
  • 3
  • 16
  • Could you show concrete example in code with what are you trying to achieve, what is the resource in question ? – John Aug 28 '15 at 06:11
  • John, When we use @Profile("dev") , it internally check for the value of spring.profiles.active in the system variables, so the resource in the question is spring.profiles.active. What i want is to have some way to tell @Profile annotation that instead of looking for spring.profiles.active system variable, look for the values of some other system variable for comparison. – Tarun Gupta Aug 28 '15 at 06:43
  • That seems like very odd requirement. – John Aug 28 '15 at 07:00
  • 1
    You cannot... Create an `ApplicationContextInitializer` that reads your custom property and add that as active profile to the `Environment`. – M. Deinum Aug 28 '15 at 09:30

0 Answers0