1.4 import引入其他配置文件
戴着假发的程序员 出品
[查看视频讲解]
我们可以通过import在一个配置文件中引入其他的配置文件。 例如:
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"> <import resource="applicationContext-service.xml"/> <import resource="applicationContext-dao.xml"/> <bean id="accountDAO_1" class="com.boxuewa.dk.demo1.dao.AccountDAO"/> </beans>
这时我们就可以这样创建容器了:
ApplicationContext ac = new ClassPathXmlApplicationContext("applicationContext.xml");
我是戴着假发的程序员,分享技术,分享经验,如果要转载,请注明:出自戴着假发的程序员

浙公网安备 33010602011771号