PropertyUtils复制属性报错

java.lang.IllegalArgumentException: Cannot invoke com.xxx.xxx.setLeaveTime on bean class 'class com.xxx.xxx.Visitor' - argument type mismatch - had objects of type "java.lang.String" but expected signature "java.sql.Timestamp"

VO(值对象)与PO(持久化对象)定义的字段完全相同,但是字段的类型不一样(类型之间不能相互进行转换),导致使用PropertyUtils工具类复制对象时报错。
教训:
使用PropertyUtils或是Beanutils工具类复制对象时,两个对象间字段类型切记要保持一致。

猜你喜欢

转载自xu-nuo.iteye.com/blog/2369661
今日推荐