Spring Configuration file Assembly Bean

Source: Internet
Author: User
<?xml version= "1.0" encoding= "UTF-8"?> <! DOCTYPE beans Public "-//spring//dtd bean//en" "Http://www.springframework.org/dtd/spring-beans.dtd" > <beans > <bean id= "Mybean" class= "Cn.com.jinlulu.pj.instance.Message" > <property name= "Message" ><!-
    -The name in this must be the same as your entity name-<value>spring!</value> </property> </bean> <bean id= "Duke" class= "Cn.com.jinlulu.pj.springinaction.Juggler" > <constructor-arg value= "/> &lt" ;/bean> <bean id= "Poeticduke" class= "Cn.com.jinlulu.pj.springinaction.PoeticJuggler" > <constructor-ar G value= "/> <constructor-arg ref=" sonnect29 "/> </bean> <bean id=" sonnect29 "class=" cn.co M.jinlulu.pj.dao.impl.sonnect29 "> </bean> <bean id=" thestage "class=" cn.com.jinlulu.pj.springinaction. Stage "factory-method=" getinstance "> </bean> <bean id=" Kenny "class=" Cn.com.jinlUlu.pj.springinaction.Instrumentalist "> <property name=" song "value=" Bigbong "></property> <pro Perty name= "instrument" ref= "saxophone" > <!--I can put this saxophone here, to prevent other bean calls, only this Kenny--<! --<bean class= "Cn.com.jinlulu.pj.dao.impl.Saxophone" ></bean> </property> <!--here cannot support Holding multiple properties can be used with the list below--<!--<property name= "instrument" ref= "Piano" ></property>-</bea N> <!--Another way of expression is the same as the one above--<!--<bean id= "Kenny" class= "Cn.com.jinlulu.pj.springinaction.Instrume Ntalist "p:song=" Bigbong "p:instrument-ref=" saxophone "/> and <bean id=" saxophone "class=" CN.COM.JINLULU.P J.dao.impl.saxophone "></bean> <bean id=" Piano "class=" Cn.com.jinlulu.pj.dao.impl.Piano "></bean > <!--From here can support multiple properties--<bean id= "Hand" class= "Cn.com.jinlulu.pj.springinaction.OneManBand" > &L T;property name= "Instruments" &Gt <list><!--can support members repeat---<ref bean= "Piano"/><!--of course this bean we've already written in front--<ref bean= 
    "Saxophone"/> <ref bean= "saxophone"/><!--the contents of this line can be displayed--</list> </property> </bean> <bean id= "Hand2" class= "Cn.com.jinlulu.pj.springinaction.OneManBand" > <property name= "Instruments" > <set><!--cannot support member repeats--<!--set can be configured in a property of type java.util.List, but ensure that members of the list type do not repeat --<ref bean= "Piano"/> <ref bean= "saxophone"/> <ref bean= "saxophone"/><!--this The contents of the line are not lost, possibly because the set cannot be duplicated, but it is not an error--</set> </property> </bean> <!--map--&G
    T
    		<bean id= "Hand3" class= "Cn.com.jinlulu.pj.springinaction.OneManBand" > <property name= "Instrumentmap" > <map> <entry key= "PIANO" value-ref= "PIANO"/> <entry key= "saxophone" value-ref= "saxophone"/
  >  		</map> </property> </bean> <!--If both the key and value in the map are string, you can also refer to this method-<! --<bean id= "Hand4" class= "Cn.com.jinlulu.pj.springinaction.OneManBand" > <property name= "Instrumentmap" >instrumentmap types are properties <props> <prop key= "Piano" >BOON</prop> <prop key= " Saxophone ">TOOT</prop> </props> </property> </bean>--<!--Some of the properties want him empty. Value (this is not common)-<bean id= "Hand5" class= "Cn.com.jinlulu.pj.springinaction.OneManBand" > <property name= " Instrumentmap "><null/></property> </bean> <!--spel-<bean id=" Kenny2 "class=
    	"Cn.com.jinlulu.pj.springinaction.Instrumentalist" > <property name= "song" Value= "#{3}" ></property> <!--<property name= "song" Value= "#{3.2}" ></property> <property name= "song" Value= "#{1e4}" &GT;&L T;/property> <propeRty name= "song" value= "#{' Chuck '}" ></property> <property name= "song" Value= ' #{"Chuck"} ' ></ Property> <property name= "song" Value= "#{false}" ></property> </bean> <!--using SP
    	El assembles a bean into the Instrument property--<bean id= "Kenny3" class= "Cn.com.jinlulu.pj.springinaction.Instrumentalist" > <property name= "instrument" value= "#{saxophone}"/> <!--<property name= "instrument" ref= "saxophone"/&G T -</bean> <bean id= "Cerl" class= "cn.com.jinlulu.pj.springinaction.Instrumentalist" > <prop Erty name= "song" Value= "#{kenny.song}"/> </bean> <!--Spel There is also a powerful feature reference method if this selectsong returns NULL, a null pointer exception is reported--&
    Gt 
    	<!--<bean id= "" class= "" > <property name= "song" Value= "#{songselector.selectsong (). toUpperCase ()}"/> This does not quote a null pointer exception means that the Selectsong () method does not call the toUpperCase () method if it returns null <property name= "song" Value= "#{songselector.selects Ong (): toUpperCase ()} "/&Gt </bean>-<!--Spel methods and constants for calling class scopes random () The method returns an unsigned double value that is greater than or equal to 0.0 and less than 1.0. --<bean id= "Math" class= "Cn.com.jinlulu.pj.springinaction.MathForMathod" > <property name= "Multiplie R "value=" #{t (Java.lang.Math). PI} "/> <property name=" Randomnumber "value=" #{t (Java.lang.Math). Random ()} "/> </bean> <!--do Two numbers add of course multiplication * Division/remainder% is also available, you can also use "1" + "" to connect strings-<!--<bean id= "" class= "" > <property name= "Adjustamo Unt "value=" #{counter.total+42} "/> </bean> <!--You can tell, it returns a Boolean type--<!--< > &L t;= >= = = can be used, but preferably in spel text Format lt gt le ge eq--<!--<bean id= "" class= "" > <property name= "Isequa L "value=" #{counter.total = = "/> </bean> <!--can use and or not OR! -<!--<bean id= "" class= "" > <property name= "largecircle" value= "#{shape.kind== ' Circle ' and Shap E.perimeter GT 10000} "/> </Bean>-<!--can use the ternary operator-<!--<bean id= "" class= "> <property name=" largecircle " Value= "#{songselector.selectsong== ' Jingle Bells '? Piano:saxophone}"/> </bean> <!--<bean id= " "Class=" "> <property name=" largecircle "value=" #{songselector.selectsong==null? Songselector.selectsong: ' saxophone '/> </bean> <!--this way can be written as follows--<!--<bean I d= "class=" "> <property name=" largecircle "value=" #{songselector.selectsong?: ' Saxophone '} "/> </bea N>-<!--expressions List can also be used this way-<!--<util:list id= "Cities" > <bean class= "" P:name= "11
    	1 "p:state=" ga "p:population=" 1145451 "/> <bean class=" "p:name=" 121 "p:state=" GA "p:population=" 1145451 "/> <bean class= "" P:name= "113" p:state= "GA" p:population= "1145451"/> <bean class= "" P:name= "211" p:state= "G A "p:population=" 1145451 "/> <bean class=" "p: Name= "131" p:state= "ga" p:population= "1145451"/> <bean class= "" P:name= "" p:state= "ga" p:population= "114545 1 "/> </util:list> <!--<bean id=" City "class=" "> <property name=" chosencity "Valu E= "#{city[2]}"/> </bean> <!--<bean id= "City" class= "" > <property name= "chosencit Y "value=" #{city[' 111 '} "/> </bean> <!--load Other profiles--<!--setting Bean is a JAVA.UTIL.P Roperties class so you can access properties-<util:properties id= "setting" location= "classpath:setting.properties"/ > <!--<bean id= "City" class= "" > <property name= "Accesstoken" value= "#{settings[" Twitter.accesstok En ']} "/> </bean> <!--systemenvironment contains all environment variables for the application environment on the machine--<bean id=" HomePath "Clas
    S= "" > <property name= "HomePath" value= "#{systemenvironment[' HOME ']}" ></property> </bean> <!--systemproperties contains JAVA all properties that are set when the application starts--<bean id= "homePath2" class= "" > <property name= "HomePath" value= "#{systemproperti es[' Application.home '} ' ></property> </bean> <!--query cities with more than 1000 population---<bean> &lt ;p roperty name= "bigcities" value= "#{cities.? [Population GT 1000]} " ></property> </bean> <!--query out the first match-<bean> <property name= "abigcity" va 
    	lue= "#{cities.^[population gt"} "></property> </bean> <!--find out the last match--<bean> <property name= "abigcity" value= "#{cities.$[population GT"} "></property> </bean> < !--Projection Collection! []--> <!--to select a specific property from each member of the collection in a new collection-<!--a collection of string that contains only the city name--<!--contains 111 121 11 3--<bean> <property name= "Citynames" value= "#{cities.! [Name]} " ></property> </bean> <!--can also have multiple--<bean> <property name= "Citynames" value= "#{cities.! [name+ ', ' +state]} ' ></property> </bean> <!--put more than 1000 cities in a new collection--<bean> <property name= " Citynames "value=" #{cities.? [Population GT 1000].! [name+ ', ' +state]} ' ></property> </bean> </beans>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.