Spring怎么引入多个xml配置文件

时间:2021-01-25 04:52:37

方式一:在web.xml中通过<context-param> 标签引入

<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath*:META-INF/spring/*.xml</param-value>
</context-param>

方式二:在Spring的applicationContext.xml中通过<import/> 标签引入

<import resource="classpath:META-INF/service.xml" />
<import resource="classpath:META-INF/huatuo-service.xml" />
<import resource="classpath:META-INF/db.xml" />
<import resource="classpath:META-INF/huatuo-db.xml" />
<import resource="classpath:META-INF/db-mapper.xml" />
<import resource="classpath:META-INF/huatuo-db-mapper.xml" />
<import resource="classpath:META-INF/webservice.xml" />
<import resource="classpath:META-INF/dubbo.xml" />
<import resource="classpath:META-INF/spring/physicalExamService.xml" />