内射老阿姨1区2区3区4区_久久精品人人做人人爽电影蜜月_久久国产精品亚洲77777_99精品又大又爽又粗少妇毛片

spring如何實(shí)現(xiàn)兩個(gè)xml配置文件間的互調(diào)

這篇文章主要介紹了spring如何實(shí)現(xiàn)兩個(gè)xml配置文件間的互調(diào),文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下

專注于為中小企業(yè)提供網(wǎng)站制作、成都網(wǎng)站制作服務(wù),電腦端+手機(jī)端+微信端的三站合一,更高效的管理,為中小企業(yè)巴林左旗免費(fèi)做網(wǎng)站提供優(yōu)質(zhì)的服務(wù)。我們立足成都,凝聚了一批互聯(lián)網(wǎng)行業(yè)人才,有力地推動了成百上千家企業(yè)的穩(wěn)健成長,幫助中小企業(yè)通過網(wǎng)站建設(shè)實(shí)現(xiàn)規(guī)模擴(kuò)充和轉(zhuǎn)變。

首先建兩個(gè)測試類

package soundsystem;
public class Dog {
  private String Cry;
  private Cat Cat;
  public void setCry(String cry) {
    Cry = cry;
  }
  public void setCat(soundsystem.Cat cat) {
    Cat = cat;
  }
  public void DogCry(){
    System.out.println("狗叫:"+Cry);
    Cat.CatCry();
  }
}
package soundsystem;
public class Cat {
  private String Cry;
  public Cat(String cry){
    this.Cry=cry;
  }
  public void CatCry(){
    System.out.println("貓叫:"+Cry);
  }
}

然后針對兩類建兩個(gè)xml配置文件

Bean_DogXML.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.xsd">

  <import resource="Bean_CatXML.xml"></import>

  <bean id="Dog" class="soundsystem.Dog">
    <property name="Cry" value="汪汪汪~"></property>
    <property name="cat" ref="Cat"></property>
  </bean>

</beans>

Bean_CatXML.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.xsd">

  <bean id="Cat" class="soundsystem.Cat">
    <constructor-arg value="喵喵~"></constructor-arg>
  </bean>
</beans>

現(xiàn)在開始測試:

package Test;

import org.junit.runner.RunWith;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import soundsystem.Cat;
import soundsystem.Dog;
@RunWith(SpringJUnit4ClassRunner.class)
public class Test {
  @org.junit.Test
  public static void main(String[] args) {
    ApplicationContext ap=new ClassPathXmlApplicationContext("config/Bean_DogXML.xml");
    Dog dog=(Dog)ap.getBean("Dog");
    dog.DogCry();
  }
}

輸出結(jié)果是:

spring如何實(shí)現(xiàn)兩個(gè)xml配置文件間的互調(diào)

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持創(chuàng)新互聯(lián)。

新聞標(biāo)題:spring如何實(shí)現(xiàn)兩個(gè)xml配置文件間的互調(diào)
本文鏈接:http://www.rwnh.cn/article48/jsddep.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供ChatGPT自適應(yīng)網(wǎng)站定制網(wǎng)站、靜態(tài)網(wǎng)站關(guān)鍵詞優(yōu)化、響應(yīng)式網(wǎng)站

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)

成都定制網(wǎng)站建設(shè)
信丰县| 萨迦县| 霍林郭勒市| 怀化市| 于田县| 曲靖市| 泸溪县| 铁力市| 宜良县| 张掖市| 施秉县| 荥经县| 新邵县| 赫章县| 灵宝市| 台湾省| 贵南县| 龙里县| 阿巴嘎旗| 南澳县| 盈江县| 乐安县| 冷水江市| 赫章县| 赤壁市| 阳高县| 仪陇县| 婺源县| 阿克陶县| 宁城县| 深水埗区| 深州市| 通许县| 凉城县| 屏边| 日土县| 普宁市| 金昌市| 西峡县| 盘山县| 弋阳县|