axios请求错误:Uncaught (in promise) TypeError: Error is not a constructor at eval 后端WHERE null=?等问题
WHERE null=?TypeError: Error is not a constructor at eval @TableId(value = "user_id"
·
1、当我们使用VUE的axios发送请求时,在浏览器开发工具网络调试会出现 错误Uncaught (in promise) TypeError: Error is not a constructor问题,一开始我以为是跨域问题,最后通过后端test测试我的功能
void test(){ System.out.println("axios请去进入"); System.out.println(userService.selectUer(3)); }
日志出现 错误
Preparing: SELECT user_id,user_name,user_password,user_wangdian,user_title FROM bank_user WHERE null=?
==> Parameters: 3(Integer)
<== Total: 0
最后通过发现是因为我的使用mybatis-plus了,实体类没有和数据库字段一样
我的表里面有个id字段,但是我并没有在User里面增加这个属性,下面将// private Integer id;注释去掉后能正常运行,所以当我们写实体类时,类属性要和数据库字段一致
@Data public class User { // private Integer id; private Integer user_id; private String user_name; private String user_password; private String user_wangdian; private String user_title; }
如果你没有id你也可以指定需要加上@TableId(value = "user_id")注解
@TableId(value = "user_id") private Integer user_id; private String user_name; private String user_password; private String user_wangdian; private String user_title; }
更多推荐
已为社区贡献1条内容
所有评论(0)