org.springframework.context.support.ClassPathXmlApplicationContext.setEnvironment()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(3.9k)|赞(0)|评价(0)|浏览(120)

本文整理了Java中org.springframework.context.support.ClassPathXmlApplicationContext.setEnvironment()方法的一些代码示例,展示了ClassPathXmlApplicationContext.setEnvironment()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ClassPathXmlApplicationContext.setEnvironment()方法的具体详情如下:
包路径:org.springframework.context.support.ClassPathXmlApplicationContext
类名称:ClassPathXmlApplicationContext
方法名:setEnvironment

ClassPathXmlApplicationContext.setEnvironment介绍

暂无

代码示例

代码示例来源:origin: cloudfoundry/uaa

context.setEnvironment(environment);
EnvironmentPropertiesFactoryBean factoryBean = new EnvironmentPropertiesFactoryBean();
factoryBean.setEnvironment(environment);

代码示例来源:origin: spring-projects/spring-integration

private ClassPathXmlApplicationContext createContext(UdpMulticastEndToEndTests launcher, String location) {
  ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext();
  applicationContext.setConfigLocation(location);
  StandardEnvironment env = new StandardEnvironment();
  Properties props = new Properties();
  props.setProperty("port", Integer.toString(launcher.getReceiverPort()));
  PropertiesPropertySource pps = new PropertiesPropertySource("ftpprops", props);
  env.getPropertySources().addLast(pps);
  applicationContext.setEnvironment(env);
  applicationContext.refresh();
  return applicationContext;
}

代码示例来源:origin: spring-projects/spring-integration

private ClassPathXmlApplicationContext createContext(UdpUnicastEndToEndTests launcher, String location) {
  ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext();
  applicationContext.setConfigLocation(location);
  StandardEnvironment env = new StandardEnvironment();
  Properties props = new Properties();
  props.setProperty("port", Integer.toString(launcher.getReceiverPort()));
  PropertiesPropertySource pps = new PropertiesPropertySource("ftpprops", props);
  env.getPropertySources().addLast(pps);
  applicationContext.setEnvironment(env);
  applicationContext.refresh();
  return applicationContext;
}

代码示例来源:origin: spring-projects/spring-amqp

env.addActiveProfile("basicAdmin");
env.addActiveProfile("basic");
context.setEnvironment(env);
context.refresh();
context.getBean(CachingConnectionFactory.class).createConnection();
env.addActiveProfile("basicAdmin");
env.addActiveProfile("ttl");
context.setEnvironment(env);
context.refresh();
channel = this.connectionFactory.createConnection().createChannel(false);

代码示例来源:origin: spring-projects/spring-amqp

@Test
public void testAdminSkipsMismatchedQueue() throws Exception {
  ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext();
  context.setConfigLocation("org/springframework/amqp/rabbit/config/MismatchedQueueDeclarationTests-context.xml");
  StandardEnvironment env = new StandardEnvironment();
  env.addActiveProfile("advancedAdmin");
  env.addActiveProfile("basic");
  context.setEnvironment(env);
  context.refresh();
  context.getBean(CachingConnectionFactory.class).createConnection();
  context.close();
  Channel channel = this.connectionFactory.createConnection().createChannel(false);
  channel.queueDeclarePassive("mismatch.bar");
  this.admin.deleteQueue("mismatch.bar");
  assertNotNull(this.admin.getQueueProperties("mismatch.foo"));
  assertNull(this.admin.getQueueProperties("mismatch.bar"));
  context = new ClassPathXmlApplicationContext();
  context.setConfigLocation("org/springframework/amqp/rabbit/config/MismatchedQueueDeclarationTests-context.xml");
  env = new StandardEnvironment();
  env.addActiveProfile("advancedAdmin");
  env.addActiveProfile("ttl");
  context.setEnvironment(env);
  context.refresh();
  channel = this.connectionFactory.createConnection().createChannel(false);
  context.getBean(CachingConnectionFactory.class).createConnection();
  assertNotNull(this.admin.getQueueProperties("mismatch.foo"));
  assertNotNull(this.admin.getQueueProperties("mismatch.bar"));
  context.close();
}

相关文章

微信公众号

最新文章

更多