gpt4 book ai didi

java - 使用 BeanUtils.copyProperties 导致参数类型不匹配

转载 作者:行者123 更新时间:2023-12-01 14:04:13 27 4
gpt4 key购买 nike

dto 对象:

public class DTOUser implements UserDetails {
/**
*
*/
private static final long serialVersionUID = -769714837633005963L;
private Long id;
private String account;
private String password;
private String statusStr;
private UserStatus status;
private int systemAdmin;
private long operator;
private String operateTime;
private String name;
private String company;
private String email;
private String telephone;
private List<DTOAuthority> dtoAuthorities = new ArrayList<DTOAuthority>();
private List<DTOAgreement> dtoAgreements = new ArrayList<DTOAgreement>();}

实体:

@Entity
@Table(name="adt_user")
public class User {
private long id;
private String account;
private String password;
private String statusStr;
private UserStatus status;
private int systemAdmin;
private long operator;
private String operateTime;
private String name;
private String company;
private String email;
private String telephone;
private Set<Authority> authorities = new HashSet<Authority>();
private Set<Agreement> agreements = new HashSet<Agreement>();}

我使用以下方法将值复制到实体,但有一个异常(exception):

java.lang.IllegalArgumentException: Cannot invoke com.hna.adt.orm.User.setAuthorities - argument type mismatch

what's wrong with it ?

BeanUtils.copyProperties(entity, value);

最佳答案

如果检查权限和协议(protocol)的类型,它们与其他类定义不匹配。为了beanutils能够正常工作,请确保属性的类型匹配。

关于java - 使用 BeanUtils.copyProperties 导致参数类型不匹配,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19064331/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com