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

歡迎訪問 生活随笔!

生活随笔

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

编程问答

依赖注入_Map类型的注入

發布時間:2024/4/13 编程问答 25 豆豆
生活随笔 收集整理的這篇文章主要介紹了 依赖注入_Map类型的注入 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

Java.util.Map 通過 <map> 標簽定義, <map> 標簽里可以使用多個 <entry> 作為子標簽. 每個條目包含一個鍵和一個值.?

必須在 <key> 標簽里定義鍵

因為鍵和值的類型沒有限制, 所以可以自由地為它們指定 <value>, <ref>, <bean> 或 <null> 元素.?

可以將 Map 的鍵和值作為 <entry> 的屬性定義: 簡單常量使用 key 和 value 來定義; Bean 引用通過 key-ref 和 value-ref 屬性定義

<?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"xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"> <bean id="personMap" class="com.learn.spring.beans.PersonMap"><property name="name" value="燕小六"></property><property name="age" value="26"></property><property name="cars"><map><entry key="AA" value-ref="car"></entry> <entry key="BB" value-ref="car1"></entry><entry key="CC" value-ref="car2"></entry></map></property></bean> </beans> package com.learn.spring.test;import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext;import com.learn.spring.beans.Book; import com.learn.spring.beans.Car; import com.learn.spring.beans.HelloWorld; import com.learn.spring.beans.Person; import com.learn.spring.beans.PersonList; import com.learn.spring.beans.PersonMap;public class Main {public static void main(String[] args) { PersonMap personMap = (PersonMap)ctx.getBean("personMap");System.out.println(personMap); } }

?

超強干貨來襲 云風專訪:近40年碼齡,通宵達旦的技術人生

總結

以上是生活随笔為你收集整理的依赖注入_Map类型的注入的全部內容,希望文章能夠幫你解決所遇到的問題。

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