Solve the problem that BeanUtils. copyProperties cannot be successfully encapsulated

  • 2021-09-16 07:01:21
  • OfStack

BeanUtils. copyProperties cannot be encapsulated

Use


BeanUtils.copyProperties(user, memeber);

Fields in both classes are like 1, but individual fields cannot be encapsulated.

At the beginning of the period, I thought that maybe the attributes of the fields were different, but I checked them carefully. Finally, I found that it was the reason why get and set method names were different.

As follows

user has a field called abc, and his get method is called getABC ();

The same field abc in member, whose get method is called getAbc ();

Finally, the fields of abc cannot be successfully encapsulated

BeanUtils. copyProperties cause of problem

When using BeanUtils. copyProperties (dest, origin),

If the following problems occur:

java.lang.IllegalArgumentException: No origin bean specified

Please check whether the origin object is NULL


Related articles: