0

I'm currently maintaining a legacy codebase where the following Spring profile configuration has been specified in the application context:

spring.profiles.active=addressbook-[usermanager|webservices],entrypoint-[form|saml]

The question is: how do I read what is specified in this example for spring.profiles.active?

Am I right in thinking that there are 4 possible profile definitions here? Namely:

addressbook-usermanager, entrypoint-form
addressbook-webservices, entrypoint-form
addressbook-usermanager, entrypoint-saml
addressbook-webservices, entrypoint-saml

Is there a way to turn on logging to see which profile is chosen and which beans get loaded for a particular profile? And if not, why they didn't get loaded?

I'm plowing through this blog post and any other kind of documentation that I can find, but I haven't found anything specific to the profile specification syntax above. Is there any documentation available?

Thanks!

Jesús Zazueta
  • 1,160
  • 1
  • 17
  • 32

1 Answers1

2

I'm not aware of any support in Spring for the syntax that you've described above. I believe that the configuration you've described will give you two active profiles:

  • addressbook-[usermanager|webservices]
  • entrypoint-[form|saml]

You can query the currently active profiles using Environment.getActiveProfiles(). To get hold of the Environment instance, you can use Spring's auto-wiring or implement EnvironmentAware.

You might also want to look at ProfileCondition. There's no logging in it, but you could use the debugger to see beans being included or excluded based on their @Profile annotation.

Andy Wilkinson
  • 108,729
  • 24
  • 257
  • 242
  • Never mind. I failed to realize that this just meant to imply that I had to choose one of each option explicitly in my configuration. As you rightly mentioned, Spring has nothing to do/does not care about what name is in there. So yeah... OSI layer 8 error *facepalm*. Thanks again! – Jesús Zazueta Sep 18 '14 at 15:24
  • ... I need coffee XD. – Jesús Zazueta Sep 18 '14 at 15:24