Skip to content

Instantly share code, notes, and snippets.

@igm
Created August 17, 2011 09:26
Show Gist options
  • Save igm/1151172 to your computer and use it in GitHub Desktop.
Save igm/1151172 to your computer and use it in GitHub Desktop.
KB_spring_profile
package foo.bar;
import org.springframework.context.ApplicationContextInitializer;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.env.ConfigurableEnvironment;
public class MyContextInitializer implements ApplicationContextInitializer<ConfigurableApplicationContext> {
public void initialize(ConfigurableApplicationContext applicationContext) {
ConfigurableEnvironment springEnvironment = applicationContext.getEnvironment();
String profile = ... // TODO add logic to select profile to activate
springEnvironment.setActiveProfiles(profile);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment