spring configured bean property details

  • spring configuration attribute tags may also be used instead of , for example, value properties may be <value> </ value> instead of tags
  • Special characters in the value <! [CDATA [ literal ]]>
  • The ref attribute property label of establishing a reference relationship between the bean
  • Bean tag can be built inside a property tag represents bean, external references can not be
  • a null value (null value is not assigned a default null) plus the use of tag <null /> tag
  • Assignment cascade configuration (such as A {B b;}) also need to set method
    class B{
    	String name;
    }
    class A{
    	B b;
    }
  • Class list with a collection attribute tag configuration
    (e.g. List) configuration

    	<bean id="id名称" class="类路径">
    		<property name="属性名(集合变量名称)">
    			<list>
    				<ref bean="类路径"/>
    			</list>
    		</property>
    	</bean>

    (Type Map) list and almost only caveat is a Map value and therefore has the corresponding key <entry> </ entry> tag

    			<map>
    				<entry key="" value-ref=""></entry>
    				<entry key="" value-ref=""></entry>
    			</map>
  • Configuration property values ​​of properties

    		<property name="name" value="spring">
    			<props key="属性名">
    				属性值
    			</props>
    			<props key="属性名2">
    				属性值2
    			</props>
    		</property>
  • When configuring a set of independent bean, using the basic set of defined set of tags can not be defined as a set of independent bean, resulting in the collection can not reference other bean case independently set by configuring the bean to solve the problem
    is first introduced in the following namespace frame eclipse out part

    and then there <util: list> tag prompt, add the following rules list in this namespace

    	<util:list id="hellos">
    		<bean id="hello1" class="com.taotao.beans.HelloWorld"></bean>
    		<bean id="hello2" class="com.taotao.beans.HelloWorld"></bean>
    		<bean id="hello3" class="com.taotao.beans.HelloWorld"></bean>
    	</util:list>

    Bean and then can be used within a namespace list

    	<bean id="id名称" class="类路径">
    		<property name="hellos" ref="hellos引用前面命名空间的bean"></property>
    	</bean>
  • p bean namespace attribute assignment need to import the namespace and p as before operation
    check can be in the namespace
     

    	<bean id="id名称" class="类路径">
    		<property name="hellos" p:hellos-ref="hellos引用前面命名空间的bean"></property>
    	</bean>

     

 

发布了242 篇原创文章 · 获赞 13 · 访问量 1万+

Guess you like

Origin blog.csdn.net/qq_41813208/article/details/103650635