💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、星火、月之暗面及文生图 广告
[TOC] # 整合多个配置文件 spring允许通过`<import>`将多个配置文件引入到一个文件中,进行配置文件的集成. 这样在启动spring容器时,仅需要指定这个合并好的配置文件就行 import元素的resource属性支持spring的标准的路径资源 | 地址前缀 | 示例 | 对应资源类型 | | --- | --- | --- | | classpath: | classpath:spring-mvc.xml | 从类路径下加载资源,classpath:和classpath:/是等价的 | | file: | file:/conf/security/spring-shiro.xml | 从文件系统目录中装载资源,可采用绝对或相对路径 | | http:// | http://www.x.com/beans.xml | 从web服务器中加载资源 | | ftp:// | ftp://www.x.com/beans.xml | 从ftp服务器中加载资源 | # 使用通配符* ~~~ ClassPathXmlApplicationContext ac = new ClassPathXmlApplicationContext("applicationContext-*.xml"); ~~~ # 创建容器时传入多个配置文件 ~~~ new ClassPathXmlApplicationContext("beans-annotation.xml", "beans-db.xml"); ~~~ # 选择主配置文件(配置文件import) ~~~ <import resource="bean.xml" /> ~~~