<? XML version="1.0" encoding="UTF-8"?> <beans xmlns= "Http://www.springframework.org/schema/beans" xmlns:xsi= "http://www.w3.org/2001/XMLSchema-instance" xsi: Schemalocation= ; <bean ID= "english_level" class=" Com.myspring.second.EnglishLevel "> <!--set method injection -- <property name="Course"> <value>level 4 </value> </property > </bean> <bean ID= "math_level" class=" Com.myspring.second.MathCourse "> <!--constructor injection -- <constructor-arg><value>1001</value></ Constructor-arg> <constructor-arg><value> discrete math </value></ constructor-arg> </bean> <bean ID= "Student" class=" Com.myspring.second.Student "> <property name="eng"> <ref Bean="English_level"/> </property > <property name="Mat"> <ref Bean="Math_level"/> </property > </bean> </Beans>For example, the above file:
- 3 Beans configured
- property's name attribute value, in the entity bean must have corresponding set method, otherwise error , error is as follows:
The Bean property ' xxx attribute ' is not writable or have an invalid setter method. Does the parameter type of the setter match the return type of the getter?
For example:< bean id = "student" class = "com.myspring.second.Student" > <property name="eng"> <ref Bean="English_level"/> </property > <property name="mat"> <ref Bean="Math_level"/> </property > </bean> for this bean, it must exist in the Student class:setEng(String string) {}setMat(String string) {}these two methods;The set method is an unknown solution, slightly ~The slag has to be stuck in the bug.
From for notes (Wiz)
>property>>name property, mamicode.com "style=" color: Configuration _blank for #ffffff "target=" >spring "Bean>>property >>name Property