spring配置文件中引入其他配置文件的方法

it2024-08-10  60

1. 在spring 配置文件中,添加如下配置:

<import resource="classpath*:/spring/other.xml" />

classpath:  src目录下。

 

2.other.xml内容如下:

<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:context="http://www.springframework.org/schema/context" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.3.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.3.xsd"> <bean id="testInterface" class="com.xuzhiwen.test.TestInterfaceImpl" /> </beans>

3. 这样就完成了xml文件的引入

转载于:https://www.cnblogs.com/beibidewomen/p/7233098.html

最新回复(0)