Spring Configuration Bean>>property>>name Properties

Source: Internet
Author: User

<? 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

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.