本文整理汇总了Java中org.springframework.web.context.support.AnnotationConfigWebApplicationContext.setEnvironment方法的典型用法代码示例。如果您正苦于以下问题:Java AnnotationConfigWebApplicationContext.setEnvironment方法的具体用法?Java AnnotationConfigWebApplicationContext.setEnvironment怎么用?Java AnnotationConfigWebApplicationContext.setEnvironment使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.web.context.support.AnnotationConfigWebApplicationContext
的用法示例。
在下文中一共展示了AnnotationConfigWebApplicationContext.setEnvironment方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: applicationContext
import org.springframework.web.context.support.AnnotationConfigWebApplicationContext; //导入方法依赖的package包/类
protected WebApplicationContext applicationContext() {
if (applicationContext == null) {
AnnotationConfigWebApplicationContext webApplicationContext = new AnnotationConfigWebApplicationContext();
Set<Class<?>> annotatedClasses = annotatedClasses();
if (annotatedClasses != null) {
annotatedClasses.iterator().forEachRemaining(webApplicationContext::register);
}
Set<? extends BeanFactoryPostProcessor> beanFactoryPostProcessors = beanFactoryPostProcessors();
if (beanFactoryPostProcessors != null) {
beanFactoryPostProcessors.iterator().forEachRemaining(webApplicationContext::addBeanFactoryPostProcessor);
}
if (this.rootApplicationContext != null) {
webApplicationContext.setParent(this.rootApplicationContext);
webApplicationContext.setEnvironment((ConfigurableEnvironment) rootApplicationContext.getEnvironment());
}
applicationContext = webApplicationContext;
}
return (WebApplicationContext) applicationContext;
}
示例2: testCustomShellProperties
import org.springframework.web.context.support.AnnotationConfigWebApplicationContext; //导入方法依赖的package包/类
@Test
public void testCustomShellProperties() throws Exception {
MockEnvironment env = new MockEnvironment();
env.setProperty("management.shell.auth.type", "simple");
AnnotationConfigWebApplicationContext ctx = new AnnotationConfigWebApplicationContext();
ctx.setEnvironment(env);
ctx.setServletContext(new MockServletContext());
ctx.register(TestShellConfiguration.class);
ctx.register(CrshAutoConfiguration.class);
ctx.refresh();
PluginLifeCycle lifeCycle = ctx.getBean(PluginLifeCycle.class);
String uuid = lifeCycle.getConfig().getProperty("test.uuid");
assertThat(uuid).isEqualTo(TestShellConfiguration.uuid);
ctx.close();
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:17,代码来源:ShellPropertiesTests.java
示例3: annotationConfigWebApplicationContext
import org.springframework.web.context.support.AnnotationConfigWebApplicationContext; //导入方法依赖的package包/类
@Test
public void annotationConfigWebApplicationContext() {
AnnotationConfigWebApplicationContext ctx = new AnnotationConfigWebApplicationContext();
ctx.setEnvironment(prodWebEnv);
ctx.setConfigLocation(EnvironmentAwareBean.class.getName());
ctx.refresh();
assertHasEnvironment(ctx, prodWebEnv);
assertEnvironmentBeanRegistered(ctx);
assertEnvironmentAwareInvoked(ctx, prodWebEnv);
}