The copyproperties method of beanutils cannot copy attributes of Non-public declared classes.

Source: Internet
Author: User

In the two-day project, because the attributes of pojo are too large, I thought of using the beanutils method copyproperties of Apache to help copy the attribute values. So I first wrote a test class.

Regardless of the result, all the copied results are null, and the result of painstaking thinking is not good. The data is searched everywhere on the Internet. Obviously, the method of copying is the same, but the result is unsatisfactory. It is always null...

Finally, I thought about it carefully. The problem may be on bean. The only difference between the demo made by myself and the demo made on the Internet is that all of them are public classes, and my class is default class .....

So we put the two beans in the test classCodeCopied out, and two other public classes are written... Finally... Come out. Now I know that the original Apache property replication method only works for public classes .... But in fact, this is not a serious problem. We would have declared all form and pojo in public... Haha

Related Article

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.