测试接口报406异常,接口中返回的是自定义的数据格式,检查发现没有添加getter和setter也没有添加@Data注解,添加@Data注解后异常解决。
@Data
public class ResultBody {
private boolean result;
private Object data;
public ResultBody() {
}
public ResultBody(boolean result, Object data) {
this.result = result;
this.data = data;
}
public ResultBody(boolean result) {
this.result = result;
}
public static ResultBody success() {
return new ResultBody(true);
}
@GetMapping
public ResultBody getAll() {
return ResultBody.success(bookService.list());
}