Spring XML文件中导入位于jar包中的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" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd "> <import resource="cms-validator-common.xml"/> <import resource="cms-validator-hibernate.xml"/> <import resource="cms-validator-service.xml"/> <import resource="cms-validator-dao.xml"/> </beans>
?
很显然,上面的方案是这些配置文件和当前的配置文件都在一个project的同一个目录中,那么如果我们想导入的配置文件在jar包,怎么处理?假设这几个配置文件在validator-rest-1.0.jar中,则可以用
<?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-3.1.xsd "> <import resource="lib/validator-rest-1.0.jar*/cms-validator-common.xml"/> <import resource="lib/validator-rest-1.0.jar*/cms-validator-hibernate.xml"/> <import resource="lib/validator-rest-1.0.jar*/cms-validator-service.xml"/> <import resource="lib/validator-rest-1.0.jar*/cms-validator-dao.xml"/> </beans>
?
只要用*号,就可以完成从jar包中import文件。
?
?
?