Close

Spring Framework - Environment Examples

Spring Framework 

Setting active profile for this Environment. Environment#setActiveProfiles will replace existing active profiles. Use Environment#addActiveProfile() to add a profile while preserving the existing profiles.

        AnnotationConfigApplicationContext context =
new AnnotationConfigApplicationContext();
context.getEnvironment()
.setActiveProfiles(PROFILE_SWING, DataConfig.PROFILE_LOCAL);
context.register(AppConfig.class);
context.refresh();




Setting active profile for this Environment. Environment#setActiveProfiles will replace existing active profiles. Use Environment#addActiveProfile() to add a profile while preserving the existing profiles.

        AnnotationConfigApplicationContext context =
new AnnotationConfigApplicationContext();
context.getEnvironment()
.setActiveProfiles(PROFILE_SWING, DataConfig.PROFILE_LOCAL);
context.register(AppConfig.class);
context.refresh();




See Also