Pages

Friday, September 14, 2012

spring how to load multiple xml files

you can do this in the following way.

ApplicationContext ctx = new ClasspathXmlApplicationContext(String[]{"spring1.xml","spring2.xml"});

Another way to handle this is to put have several xml configuration files. Then export all of them to one file like below

<beans xmlns="http://www.springframework.org/schema/beans"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beanshttp://www.springframework.org/schema/beans/spring-beans-2.5.xsd">

<import resource="connection/connection.xml"/>
<import resource="common/common.xml"/>
<import resource="moduleA/moduleA.xml"/>
</beans>

No comments:

Post a Comment