报错UserInfo()' in 'com.example.gmall.cart.pojo.UserInfo' cannot be applied to '(long, java.lang.String)'的原因

新建pojo类

@Data
public
class UserInfo { private Long userId; private String userKey; }

使用Lombook中的data注解,但是在使用时报错

UserInfo()' in 'com.example.gmall.cart.pojo.UserInfo' cannot be applied to '(long, java.lang.String)'

 

 

 

原因:pojo类只是用了Data注解,缺少了构造方法,

解决:使用注解@AllArgsConstructor  @NoArgsConstructor 或者直接进行构造

 

@Data
@AllArgsConstructor
@NoArgsConstructor
public class UserInfo {
    private Long userId;
    private String userKey;
}

 

posted @ 2022-01-30 00:55  Yapi酱  阅读(905)  评论(0)    收藏  举报