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

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

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

ClassPathXmlApplicationContext.getEnvironment介绍

暂无

代码示例

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

public static void main(String[] args) {
  List<String> languages = Arrays.asList(new String[]{"groovy","ruby","javascript","python"});
  if (args.length != 1) {
    usage();
  }
  String lang = args[0];
  if (!StringUtils.hasText(lang)){
    usage();
  }
  lang = lang.toLowerCase();
  if (!languages.contains(lang)){
    usage();
  }
  /*
   * Create an application context and set the active profile to configure the
   * corresponding scripting implementation
   */
  ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext();
  ctx.getEnvironment().setActiveProfiles(lang);
  ctx.setConfigLocation("/META-INF/spring/integration/cafeDemo.xml");
  ctx.refresh();
}

代码示例来源:origin: kaaproject/kaa

MutablePropertySources sources = ctx.getEnvironment().getPropertySources();
for (String propertyFile : appPropertiesFiles) {
 try {

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

@Test
public void testBeanFactoryProfileRespected() {
  GenericApplicationContextFactory factory = new GenericApplicationContextFactory(
      new ClassPathResource(ClassUtils.addResourcePathToPackagePath(getClass(), "profiles.xml")));
  @SuppressWarnings("resource")
  ClassPathXmlApplicationContext parentContext = new ClassPathXmlApplicationContext(ClassUtils.addResourcePathToPackagePath(
      getClass(), "parent-context.xml"));
  parentContext.getEnvironment().setActiveProfiles("preferred");
  factory.setApplicationContext(parentContext);
  @SuppressWarnings("resource")
  ConfigurableApplicationContext context = factory.createApplicationContext();
  assertEquals("test-job", context.getBeanNamesForType(Job.class)[0]);
  assertEquals("spam", context.getBean("test-job", Job.class).getName());
}

代码示例来源:origin: stackoverflow.com

ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(new String[] {"your_config.xml"}, false);
// all sorts of constructors, many options for finding the resource
ResourcePropertySource properties = new ResourcePropertySource("path/to/my.properties");
context.getEnvironment().getPropertySources().addLast(properties);
context.refresh();

代码示例来源:origin: stackoverflow.com

//load the appcontext with refresh value as false
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
          new String[] { "classpath:appcontext.xml" }, false);
//add the props file
context.getEnvironment().getPropertySources().addFirst(new ResourcePropertySource("classpath:app.properties"));
//refresh the context
context.refresh();

代码示例来源:origin: stackoverflow.com

ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext();
 ctx.setConfigLocation("applicationContext.xml");
 ctx.getEnvironment().getPropertySources().addLast(new FooPropertySource());
 ctx.refresh();

代码示例来源:origin: dsukhoroslov/bagri

ctx.getEnvironment().getPropertySources().addFirst(pps);
String contextPath = System.getProperty(pn_config_path);
ctx.setConfigLocation("file:" + contextPath + "/spring/admin-schema-context.xml");

代码示例来源:origin: dsukhoroslov/bagri

ctx.getEnvironment().getPropertySources().addFirst(pps);
String contextPath = System.getProperty(pn_config_path);
ctx.setConfigLocation("file:" + contextPath + "/spring/cache-xqj-context.xml");

代码示例来源:origin: googleads/aw-reporting

appCtx.getEnvironment().setActiveProfiles(sqldbType.name());

相关文章

微信公众号

最新文章

更多