1. 程式人生 > >SPRING中value和ref的簡寫形式

SPRING中value和ref的簡寫形式

property常規寫法:
<property name="myProperty"> 
      <value>hello</value> 
</property> 
<constructor-arg>  
  <value>hello</value> 
</constructor-arg>  
<entry key="myKey"> 
  <value>hello</value> 
</entry> 
簡寫:
<property name="myProperty" value="hello"/> 
<constructor-arg value="hello"/>  
<entry key="myKey" value="hello"/> 

ref常規寫法:
<property name="myProperty">  
  <ref object="anotherObject"/> 
</property> 
<constructor-arg index="0">  
  <ref object="anotherObject"/>  
</constructor-arg> 
簡寫:
<property name="myProperty" ref="anotherObject"/> 
<constructor-arg index="0" ref="anotherObject"/> 
key ref常規寫法:
<entry>  
  <key> 
     <ref object="MyKeyObject"/> 
  </key>  
  <ref object="MyValueObject"/>  
</entry> 
簡寫:
<entry key-ref="MyKeyObject" value-ref="MyValueObject"/>