首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 其他教程 > 开源软件 >

spring引出多个配置文件

2012-12-15 
spring引入多个配置文件?1、web.xml引入配置文件listenerlistener-classorg.springframework.web.conte

spring引入多个配置文件

?

1、web.xml引入配置文件

<listener><listener-class>org.springframework.web.context.ContextLoaderListener</listener-class></listener><!-- spring引入多个配置文件的方法 --><context-param><param-name>contextConfigLocation</param-name><param-value>/WEB-INF/config/spring/applicationContext.xml,/WEB-INF/config/spring/applicationContext_bean_*.xml,</param-value></context-param>

?

2、如果是非j2ee应用直接程序加载.

ApplicationContext act = new ClassPathXmlApplicationContext(new String[]{"bean1.xml","bean2.xml"});BeanDefinitionRegistry reg = new DefaultListableBeanFactory();XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(reg);reader.loadBeanDefinitions(new ClassPathResource("bean1.xml"));reader.loadBeanDefinitions(new ClassPathResource("bean2.xml"));BeanFactory bf = (BeanFactory)reg;
?

热点排行