Feign接口方法返回类型为R<String>,接口实现用R.fail(""),会报反序列化异常

Blade 未结 1 540
chenrc
chenrc 剑童 2023-01-05 00:33

"Error while extracting response for type [org.springblade.core.tool.api.R<java.lang.String>] and content type [application/json;charset=UTF-8]; nested exception is org.springframework.http.converter.HttpMessageNotReadableException: JSON parse error: Cannot deserialize instance of `java.lang.String` out of START_OBJECT token; nested exception is com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot deserialize instance of `java.lang.String` out of START_OBJECT token\n at [Source: (PushbackInputStream); line: 1, column: 36] (through reference chain: org.springblade.core.tool.api.R[\"data\"])

1条回答
  • 2023-01-05 00:35

    代码具体是这样的

    public R<String> test(){

        return R.fail("异常");

    }

    0 讨论(0)
提交回复