<!--ID: Identifies the ID in the container, uniquely Class:bean the full class name, and creates the bean in the IOC container by reflection, all requiring the bean to have an argument-free constructor -<BeanID= "HelloWorld"class= "Com.jx.spring.beans.HelloWorld">//Parameter injection< Propertyname= "message"value= "Spring"></Bean>
Private String message; Public String getMessage () { return message; } Public void setmessage (String message) { this. Message = message; } Public void log () { System.out.println (">>>>>>>>>" +message); }
1 <!--by constructing the bean properties, you can specify the parameter position and the parameter type to differentiate the overloaded constructors -2 <BeanID= "Car"CALSS= "Com.jx.spring.benas.Car">3 <Constructorvalue= "BMW"Index= "0"type= "Java.lang.String">4 </Constructor>5 <Constructorvalue= "500000"Index= "1"type= "int">6 </Constructor>7 </Bean>
// write-only constructor Public int Price ) { Super(); this. Brand = brand; this. Price = Price ; }
Spring use Tutorial (ii) Configuring beans