本文整理了Java中org.springframework.context.support.ClassPathXmlApplicationContext.setConfigLocation()
方法的一些代码示例,展示了ClassPathXmlApplicationContext.setConfigLocation()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ClassPathXmlApplicationContext.setConfigLocation()
方法的具体详情如下:
包路径:org.springframework.context.support.ClassPathXmlApplicationContext
类名称:ClassPathXmlApplicationContext
方法名:setConfigLocation
暂无
代码示例来源: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: spring-projects/spring-batch
@Test
public void testAllowBeanOverride() {
ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext();
applicationContext.setConfigLocation("org/springframework/batch/core/configuration/xml/BeanDefinitionOverrideTests-context.xml");
applicationContext.refresh();
}
代码示例来源:origin: spring-projects/spring-batch
@Test
public void testAllowBeanOverrideFalse() {
ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext();
applicationContext.setAllowBeanDefinitionOverriding(false);
applicationContext.setConfigLocation("org/springframework/batch/core/configuration/xml/BeanDefinitionOverrideTests-context.xml");
applicationContext.refresh();
}
}
代码示例来源:origin: spring-projects/spring-security
@Test
public void registerDataValueProcessorOnlyIfNotRegistered() throws Exception {
try (ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext()) {
context.setAllowBeanDefinitionOverriding(false);
context.setConfigLocation(this.xml("RegisterDataValueProcessorOnyIfNotRegistered"));
context.refresh();
}
}
代码示例来源:origin: spring-projects/spring-batch
@Test
public void testRemoteChunkingMasterReplyChannelAttrAssert() throws Exception {
ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext();
applicationContext.setValidating(false);
applicationContext.setConfigLocation("/org/springframework/batch/integration/config/xml/RemoteChunkingMasterParserMissingReplyChannelAttrTests.xml");
try {
applicationContext.refresh();
fail();
} catch (BeanDefinitionStoreException e) {
assertTrue("Nested exception must be of type IllegalArgumentException", e.getCause() instanceof IllegalArgumentException);
IllegalArgumentException iae = (IllegalArgumentException) e.getCause();
assertTrue("Expected: " + "The reply-channel attribute must be specified" + " but got: " + iae.getMessage(),
"The reply-channel attribute must be specified".equals(iae.getMessage()));
}
}
代码示例来源:origin: spring-projects/spring-batch
@Test
public void testRemoteChunkingSlaveItemWriterAttrAssert() throws Exception {
ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext();
applicationContext.setValidating(false);
applicationContext.setConfigLocation("/org/springframework/batch/integration/config/xml/RemoteChunkingSlaveParserMissingItemWriterAttrTests.xml");
try {
applicationContext.refresh();
fail();
} catch (BeanDefinitionStoreException e) {
assertTrue("Nested exception must be of type IllegalArgumentException", e.getCause() instanceof IllegalArgumentException);
IllegalArgumentException iae = (IllegalArgumentException) e.getCause();
assertTrue("Expected: " + "The item-writer attribute must be specified" + " but got: " + iae.getMessage(),
"The item-writer attribute must be specified".equals(iae.getMessage()));
}
}
代码示例来源:origin: spring-projects/spring-batch
@Test
public void testRemoteChunkingSlaveIdAttrAssert() throws Exception {
ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext();
applicationContext.setValidating(false);
applicationContext.setConfigLocation("/org/springframework/batch/integration/config/xml/RemoteChunkingSlaveParserMissingIdAttrTests.xml");
try {
applicationContext.refresh();
fail();
} catch (BeanDefinitionStoreException e) {
assertTrue("Nested exception must be of type IllegalArgumentException", e.getCause() instanceof IllegalArgumentException);
IllegalArgumentException iae = (IllegalArgumentException) e.getCause();
assertTrue("Expected: " + "The id attribute must be specified" + " but got: " + iae.getMessage(),
"The id attribute must be specified".equals(iae.getMessage()));
}
}
代码示例来源:origin: spring-projects/spring-batch
@Test
public void testRemoteChunkingMasterIdAttrAssert() throws Exception {
ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext();
applicationContext.setValidating(false);
applicationContext.setConfigLocation("/org/springframework/batch/integration/config/xml/RemoteChunkingMasterParserMissingIdAttrTests.xml");
try {
applicationContext.refresh();
fail();
} catch (BeanDefinitionStoreException e) {
assertTrue("Nested exception must be of type IllegalArgumentException", e.getCause() instanceof IllegalArgumentException);
IllegalArgumentException iae = (IllegalArgumentException) e.getCause();
assertTrue("Expected: " + "The id attribute must be specified" + " but got: " + iae.getMessage(),
"The id attribute must be specified".equals(iae.getMessage()));
}
}
代码示例来源:origin: spring-projects/spring-batch
@Test
public void testRemoteChunkingSlaveOutputChannelAttrAssert() throws Exception {
ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext();
applicationContext.setValidating(false);
applicationContext.setConfigLocation("/org/springframework/batch/integration/config/xml/RemoteChunkingSlaveParserMissingOutputChannelAttrTests.xml");
try {
applicationContext.refresh();
fail();
} catch (BeanDefinitionStoreException e) {
assertTrue("Nested exception must be of type IllegalArgumentException", e.getCause() instanceof IllegalArgumentException);
IllegalArgumentException iae = (IllegalArgumentException) e.getCause();
assertTrue("Expected: " + "The output-channel attribute must be specified" + " but got: " + iae.getMessage(),
"The output-channel attribute must be specified".equals(iae.getMessage()));
}
}
代码示例来源:origin: spring-projects/spring-batch
@Test
public void testRemoteChunkingSlaveInputChannelAttrAssert() throws Exception {
ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext();
applicationContext.setValidating(false);
applicationContext.setConfigLocation("/org/springframework/batch/integration/config/xml/RemoteChunkingSlaveParserMissingInputChannelAttrTests.xml");
try {
applicationContext.refresh();
fail();
} catch (BeanDefinitionStoreException e) {
assertTrue("Nested exception must be of type IllegalArgumentException", e.getCause() instanceof IllegalArgumentException);
IllegalArgumentException iae = (IllegalArgumentException) e.getCause();
assertTrue("Expected: " + "The input-channel attribute must be specified" + " but got: " + iae.getMessage(),
"The input-channel attribute must be specified".equals(iae.getMessage()));
}
}
代码示例来源:origin: spring-projects/spring-batch
@Test
public void testRemoteChunkingMasterMessageTemplateAttrAssert() throws Exception {
ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext();
applicationContext.setValidating(false);
applicationContext.setConfigLocation("/org/springframework/batch/integration/config/xml/RemoteChunkingMasterParserMissingMessageTemplateAttrTests.xml");
try {
applicationContext.refresh();
fail();
} catch (BeanDefinitionStoreException e) {
assertTrue("Nested exception must be of type IllegalArgumentException", e.getCause() instanceof IllegalArgumentException);
IllegalArgumentException iae = (IllegalArgumentException) e.getCause();
assertTrue("Expected: " + "The message-template attribute must be specified" + " but got: " + iae.getMessage(),
"The message-template attribute must be specified".equals(iae.getMessage()));
}
}
代码示例来源:origin: spring-projects/spring-batch
@Test
public void testRemoteChunkingMasterStepAttrAssert() throws Exception {
ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext();
applicationContext.setValidating(false);
applicationContext.setConfigLocation("/org/springframework/batch/integration/config/xml/RemoteChunkingMasterParserMissingStepAttrTests.xml");
try {
applicationContext.refresh();
fail();
} catch (BeanDefinitionStoreException e) {
assertTrue("Nested exception must be of type IllegalArgumentException", e.getCause() instanceof IllegalArgumentException);
IllegalArgumentException iae = (IllegalArgumentException) e.getCause();
assertTrue("Expected: " + "The step attribute must be specified" + " but got: " + iae.getMessage(),
"The step attribute must be specified".equals(iae.getMessage()));
}
}
代码示例来源: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-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
assertEquals(2, evalContexts.size());
ClassPathXmlApplicationContext child = new ClassPathXmlApplicationContext(parent);
child.setConfigLocation("org/springframework/integration/expression/ChildContext-context.xml");
child.refresh();
代码示例来源:origin: mercyblitz/thinking-in-spring-boot-samples
public static void main(String[] args) {
// 构建 XML 配置驱动 Spring 上下文
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext();
// 设置 XML 配置文件的位置
context.setConfigLocation("classpath:/META-INF/spring/context.xml");
// 启动上下文
context.refresh();
// 获取名称为 "chineseNameRepository" Bean 对象
NameRepository nameRepository = (NameRepository) context.getBean("chineseNameRepository");
// 输出用户名称:[张三, 李四, 小马哥]
System.out.printf("nameRepository.findAll() = %s \n", nameRepository.findAll());
}
}
代码示例来源:origin: kiegroup/droolsjbpm-integration
public static KieModuleModel fromXML(File kModuleFile, ReleaseId releaseId){
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(kModuleFile.getAbsolutePath());
context.setConfigLocation(kModuleFile.getAbsolutePath());
context.refresh();
context.registerShutdownHook();
return null;//kieSpringApplicationListener.getKieModuleModel();
}
代码示例来源:origin: org.kie/kie-spring
public static KieModuleModel fromXML(File kModuleFile, ReleaseId releaseId){
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(kModuleFile.getAbsolutePath());
context.setConfigLocation(kModuleFile.getAbsolutePath());
context.refresh();
context.registerShutdownHook();
return null;//kieSpringApplicationListener.getKieModuleModel();
}
代码示例来源:origin: kiegroup/droolsjbpm-integration
public static KieModuleModel fromXML(java.net.URL kModuleUrl, ReleaseId releaseId){
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext();
KModuleBeanFactoryPostProcessor beanFactoryPostProcessor = new KModuleBeanFactoryPostProcessor(kModuleUrl, context);
beanFactoryPostProcessor.setReleaseId(releaseId);
context.addBeanFactoryPostProcessor(beanFactoryPostProcessor);
context.setConfigLocation(kModuleUrl.toExternalForm());
context.refresh();
context.registerShutdownHook();
return null;//kieSpringApplicationListener.getKieModuleModel();
}
代码示例来源:origin: org.kie/kie-spring
public static KieModuleModel fromXML(java.net.URL kModuleUrl, ReleaseId releaseId){
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext();
KModuleBeanFactoryPostProcessor beanFactoryPostProcessor = new KModuleBeanFactoryPostProcessor(kModuleUrl, context);
beanFactoryPostProcessor.setReleaseId(releaseId);
context.addBeanFactoryPostProcessor(beanFactoryPostProcessor);
context.setConfigLocation(kModuleUrl.toExternalForm());
context.refresh();
context.registerShutdownHook();
return null;//kieSpringApplicationListener.getKieModuleModel();
}
内容来源于网络,如有侵权,请联系作者删除!