Could not find a getter for ... in class ... Analysis of the causes of exceptions

Source: Internet
Author: User
 

In the Java project development process for the spring+hibernate framework, you often encounter such errors:

could not find a getter for ... in class ...


can be caused as follows:

1. There is really no write getter method (occurrence: 1)

2.*.hmb.xml file property names and Pojo inconsistencies (*.hbm.xml and *.java are not connected well, Inconsistent), the field properties are not properly configured, for example, the address of the *.java in *.hmb.xml (explicitly indicates the full path of the reference package), mapping errors, and when multiple primary keys are configured incorrectly for the generated federated primary key, spelling errors (including multiple spaces), and so on (probability of occurrence: 48%)

3. Method Write wrong/method name write wrong, want to write according to JavaBean writing standard, otherwise hit to die also can not find where wrong (occurrence probability: 50%)

Here mention: Get/set is not allowed the method name has consecutive two uppercase letters, for example

Public String Getodptype () {

        return this.odptype;

}

public void Setodptype (string      odptype) {

This.odptype = Odptype;

}

If you write it in this way, you will report an error that the getter for Odptype is not found, but you can write the

public String odptype as follows;

Public String getodptype () {

        return this.odptype;

}

public void Setodptype (string      odptype) {

This.odptype = Odptype;

}

4. Other unknown cause (occurrence probability: 1)

(CSDN) To find the wrong way, follow the error information from the forward step by step to find, I encountered the error information solution is in the screenshot of the path of the file to solve.

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.