Spring Boot:关于“No converter found for return value of type: class xxx”

Spring Boot:关于“No converter found for return value of type: class xxx”

     今天发生了一件愚蠢的错误

        下面是我写的统一返回类,发现问题了吗?

        没有加@Data注解,也没有设置get,set方法

        我还设置了全局异常处理返回的也是这个类

        导致接口测试的时候不管是不是非法输入,一直收到的都是空json串

        真是无语死了,找了20多分钟才找到问题,真是粗心一小下,bug找半天

public class Result {
    private Object data;
    private boolean status;
    private String msg;
    public Result ok(){
        status=true;
        return this;
    }
    public Result ok(Object data){
        this.status=true;
        this.data=data;
        return this;
    }
    public Result no(String msg){
        this.status=false;
        this.msg=msg;
        return this;
    }
    public Result no(Throwable throwable){
        this.status=false;
        this.msg=throwable.getMessage();
        return this;
    }
}

`

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值