spring依赖注入配置及简写

一、构造器注入
1)常量值:
简写:<constructor-arg index="0" value="常量" />
全写:<constructor-arg index="0"><value>常量</value></constructor-arg>
2)引用:
简写:<constructor-arg index="0" ref="引用" />
全写:<constructor-arg index="0"><ref bean="引用"/></constructor-arg>
二、Setter注入
1)常量值
简写:<property name="message" value="常量"/>
全写:<property name="message"><value>常量</value></ property>
2)引用
简写:<property name="message" ref="引用"/>
全写:<property name="message"><ref bean="引用"/></ property>
3)数组:<array>没有简写形式
4)列表:<list>没有简写形式
5)集合:<set>没有简写形式
6)字典
简写:<map>
         <entry key="键常量" value="值常量"/>
         <entry key-ref="键引用" value-ref="值引用"/>
      </map>
全写:<map>
         <entry><key><value>键常量</value></key><value>值常量</value></entry>
         <entry><key><ref bean="键引用"/></key><ref bean="值引用"/></entry>
      </map>
7)Properties:没有简写形式

猜你喜欢

转载自shitou-2016.iteye.com/blog/2302017