报错信息:
Resolved [org.springframework.web.HttpMediaTypeNotAcceptableException: Could not find acceptable representation]
前面经过调试确定了问题不出在自己的项目代码中,返回的通用结果集的结果是符合预期的
但是报406错误,
{ "timestamp": "2024-07-14T14:40:03.348+00:00", "status": 406, "error": "Not Acceptable", "path": "/user/login" }
正当我百思不得其解之时,突然看到
这位同学没写@Data注解,我大致猜到了原因,尝试把private全部改成public
不出意外的解决了
猜测问题是由于springboot 在进行处理的的时候,通过反射调用发现没有getter或setter方法,而又没有@Data注解默认提供的getter/setter,又是private属性,导致不能正常运行
解决方法1:
加@Data注解
解决方法2:
手动添加getter/setter
解决方法3:
设置为public属性