Created
August 17, 2011 09:26
-
-
Save igm/1151172 to your computer and use it in GitHub Desktop.
KB_spring_profile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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