报错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;
}

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM