日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

spring11:为应用指定多个spring配置文件

發布時間:2025/6/15 编程问答 15 豆豆
生活随笔 收集整理的這篇文章主要介紹了 spring11:为应用指定多个spring配置文件 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

? 平等關系的配置文件

? 將配置文件分解為地位平等的多個配置文件,并將所有配置文件的路徑定義為一個String數組,將其作為容器

初始化參數出現.

? 各配置文件間為并列關系,不分主次。

比如以下 spring-school.xml, spring-student.xml就是平等關系配置文件。

spring-student.xml

<?xml version="1.0" encoding="UTF-8"?> <!-- 引用Spring的多個Schema空間的格式定義文件 --> <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:context="http://www.springframework.org/schema/context"xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd "><bean id="student" class="com.atChina.Test7.Student" autowire="byType"><property name="name" value="吳用"/><property name="age" value="20" /></bean> </beans>

?spring-school.xml

<?xml version="1.0" encoding="UTF-8"?> <!-- 引用Spring的多個Schema空間的格式定義文件 --> <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:context="http://www.springframework.org/schema/context"xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd "><bean id="xuexiao" class="com.atChina.Test7.School"><property name="name" value="同濟大學"/><property name="address" value="上海市" /></bean> </beans> @Testpublic void test1(){// 加載平等關系的配置文件String configLocation1 = "com/atChina/Test7/spring-student.xml"; // 類路徑的根目錄String configLocation2 = "com/atChina/Test7/spring-school.xml"; // 類路徑的根目錄ApplicationContext ctx = new ClassPathXmlApplicationContext(configLocation1,configLocation2);Student ss = (Student)ctx.getBean("student");System.out.println("stduent:"+ss);}

?

?包含關系的配置文件

total.xml文件如下?

<?xml version="1.0" encoding="UTF-8"?> <!-- 引用Spring的多個Schema空間的格式定義文件 --> <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:context="http://www.springframework.org/schema/context"xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd "><!-- 包含關系的配置文件: 一個總的文件,把其他文件包含進來,總的文件一般是不定義bean對象語法方式: <import resource="其他配置文件的位置">關鍵字 "classpath:"表示類路徑<import resource="classpath:com/atChina/Test8/spring-school.xml"/><import resource="classpath:com/atChina/Test8/spring-student.xml"/>--><!-- 在包含關系的配置文件中,還可以使用通配符*,表示0或多個字符 使用通配符注意事項:總的文件名稱不能包含在通配符的范圍內,比如,total.xml不能叫做spring-total.xml,避免造成死循環--><import resource="classpath:com/atChina/Test8/spring-*.xml"/> </beans> @Testpublic void test1(){String configLocation = "com/atChina/Test8/total.xml"; // 類路徑的根目錄ApplicationContext ctx = new ClassPathXmlApplicationContext(configLocation);Student ss = (Student)ctx.getBean("student");System.out.println("stduent:"+ss);}

?

?

總結

以上是生活随笔為你收集整理的spring11:为应用指定多个spring配置文件的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。

主站蜘蛛池模板: 人人搞人人 | 欧美特级特黄aaaaaa在线看 | 91麻豆成人精品国产免费网站 | 91精品国产色综合久久不8 | www.精品一区| 国产精品自拍合集 | 欧美中文在线观看 | 欧美黄色一级视频 | jizz在线播放| 欧美日韩一区二区三区在线视频 | 国产亚洲黄色片 | 黄色一级大片免费看 | 天天干夜夜嗨 | 欧美色xxxxx 日本精品一区二区三区四区的功能 | 亚州久久久 | 亚洲最新在线视频 | proumb性欧美在线观看 | 欧美毛片在线 | 欧美嘿咻视频 | 污视频网站在线观看 | 精品人妻一区二区免费 | 国产精品无码内射 | 女人洗澡一级特黄毛片 | 日韩a∨| 亚洲天堂高清 | 亚洲国产视频在线 | 亚洲宅男天堂 | 97超碰人人模人人人爽人人爱 | 久久国产一 | 国产精品毛片一区二区在线看舒淇 | 欧美一区二区精品 | 91精品国产自产91精品 | a级黄色片免费看 | 男人懂的网站 | 亚洲精品午夜国产va久久成人 | www.国产区 | 色五丁香 | 一级激情片| www.香蕉视频在线观看 | 911国产视频 | 99热青青草| 久久国产精品无码一级毛片 | 涩涩网站在线看 | 亚洲男女在线 | 国产人人草| 先锋影音av资源站 | www.久久色| 亚洲AV乱码国产精品观看麻豆 | 久久久久国产精品熟女影院 | 成人免费午夜 | 女同一区二区三区 | 国产精品电影一区二区 | 91网视频 | 肉色丝袜脚交一区二区 | 久久99久久99| 色欲av无码一区二区三区 | 天堂av8| 日韩精品免费观看 | 香蕉视频三级 | 久久综合狠狠综合久久综合88 | 国产婷婷一区二区三区久久 | 日本成人a| 国产精品老熟女视频一区二区 | 久久精品欧美视频 | 亚洲欧美综合一区 | 91视频com| 久久人人爽人人爽人人 | 大地资源中文在线观看免费版 | 国产麻豆电影在线观看 | 亚洲日本综合 | 精品一区二区三区三区 | 成全影视在线观看第8季 | 日韩免费高清一区二区 | 伊人久久九 | 污片免费观看 | 亚洲av色区一区二区三区 | 在线观看精品视频 | 亚洲精品一二 | 久久靖品| 国产日本在线观看 | 欧美在线视频播放 | 一级在线看 | 天堂精品一区二区三区 | 精品理论片 | 农村妇女一区二区 | 亚洲精品一区二区三区蜜臀 | 欧美日韩高清免费 | 久久成人免费视频 | 白石茉莉奈中文字幕在 | 被各种性器调教到哭vk | 蜜臀久久99精品久久久久久 | 亚洲欧美日韩在线不卡 | 欧美一级黄色大片 | 麻豆导航 | 脱美女衣服亲摸揉视频 | 熟妇人妻精品一区二区三区视频 | 精品国自产在线观看 | 狠狠干少妇| 99插插插 |