• 注入 list

      1. <bean id="..." class="...">
      2. <property name="...">
      3. <list>
      4. <value>张三</value>
      5. <value>李四</value>
      6. <value>王五</value>
      7. <!-- 注入 bean -->
      8. <ref bean="..."/>
      9. </list>
      10. </property>
      11. </bean>
    • 注入 set

      1. <bean id="..." class="...">
      2. <property name="...">
      3. <set>
      4. <value>张三</value>
      5. <value>李四</value>
      6. <value>王五</value>
      7. <!-- 注入 bean -->
      8. <ref bean="..."/>
      9. </set>
      10. </property>
      11. </bean>
    • 注入 map

      1. <bean id="..." class="...">
      2. <property name="...">
      3. <map>
      4. <entry key="name" value="张三" />
      5. <!-- 注入 bean -->
      6. <entry key="age" value-ref="..." />
      7. </map>
      8. </property>
      9. </bean>
    • 注入 property

      1. <bean id="..." class="...">
      2. <property name="...">
      3. <props>
      4. <prop key="name">张三</prop>
      5. <prop key="age">20</prop>
      6. </props>
      7. </property>
      8. </bean>
    • 注入 null 和空字符串

      1. <bean id="..." class="...">
      2. <!-- 注入空字符串 -->
      3. <property name="..." value="" />
      4. <!-- 注入 null -->
      5. <property name="..."><null/></property>
      6. </bean>