Occurs when you use spring injection when the is not writable or have an invalid setter method

Source: Internet
Author: User

Defined in Web-application-config.xml

<bean id= "Employeeservicedest" class= "Com.service.EmployeeServiceImpl" >
<flex:remoting-destination/>
<property name= "Esysdao" ref= "Esysdao"/>
</bean>

As a result, a run-time error occurred:

Org.springframework.beans.factory.BeanCreationException:Error creating Bean with Name ' employeeservicedest ' defined In ServletContext resource [/web-inf/web-application-config.xml]: Error setting property values; Nested exception is Org.springframework.beans.NotWritablePropertyException:Invalid property ' Esyerdao ' of Bean class [ Com.service.EmployeeServiceImpl]:

The Bean property ' Esyerdao ' was not writable or had an invalid setter method. Does the parameter type of the setter match the return type of the getter?

Among them, "Bean property ' Esyerdao ' are not writable or have an invalid setter method" is a critical error.

Originally, the Set and get methods need to be defined in Employeeserviceimpl.

public void Setesysdao (Esysdao Esysdao) {
This.esyerdao= Esysdao;
}

Public Esysdao Getesysdao () {
return Esysdao;
}

------------------------

Supplementary, case is strictly differentiated, <property name= "Esyerdao" ref= "Esyerdao"/> and <property name= "Esyerdao" ref= "Esyerdao"/> is not the same, for Name= "Esyerdao", define set and get methods in Employeeserviceimpl with lowercase setesysdao and Getesysdao:
public void Setesysdao (Esysdao Esysdao) {
This.esysdao= Esysdao;
}

Public Esysdao Getesysdao () {
return Esysdao;
}

-----------------------------------------------------------------

In addition, each <property name= "xxxx" ref= "xxxxx"/>, you must define the set and get methods in class.

One can not be less, indeed is a meticulous work.

Recently, as a result of the project team needs, began to learn jsf+spring+hibernate.

During the debugging of an online example, exception information such as headers appears during the boot Tomcat process.

Finally, through the analysis of colleagues to find the reason, in the Applicationcontext.xml configuration has a problem, the inside of the Bean property name is wrong.

But in the beginning of the Java file to find.

Some of the contents of the Java file are attached as follows:

public class Loginservice implements Iloginservice

{

Private Logindao Logindao; Here the property is named Logindao

}

But the Applicationcontext.xml is configured as follows:

<bean id= "Loginservice" class= "Vo. Loginservice ">

<property name= "Logindao" >//Here is different from the above name

<ref local= "Logindao" >

</property>

</bean>

After modifying the XML file, the problem is resolved.

Occurs when you use spring injection when the is not writable or have an invalid setter method

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.