我得到org.springframework.http.converter.HttpMessageNotReadableException,它在重新启动服务器后得到解决

时间:2018-06-20 08:48:38

标签: java spring-boot jackson

这里的问题是,重新启动服务器后,相同的请求可以正常工作。

这是stackTrace错误 无法读取HTTP消息:org.springframework.http.converter.HttpMessageNotReadableException:JSON解析错误:无法从START_OBJECT令牌中反序列化java.lang.String实例;嵌套异常是com.fasterxml.jackson.databind.JsonMappingException:无法从START_OBJECT令牌中反序列化java.lang.String实例

这是请求处理程序

@PostMapping("/buy-data")
@ApiOperation(value = "Guest buy data")
public ResponseEntity<?> buyData(@Valid @RequestBody BuyDataPaymentDto 
paymentDto, Errors errors,@RequestParam(defaultValue = "web") String channel) 
{
   ...
}

这是BuyDataPaymentDto

public class BuyDataPaymentDto {

    private long productId;
    private String transactionId;
    private String status;
    private long paymentId;
    private String cardLast4Digit;
    private long networkId;
    private String transactionRef;
    @NotEmpty(message = "Receiver's msisdn cannot be blank")
    private String receiverMsisdn;

    public BuyDataPaymentDto() {
    }

    public long getProductId() {
        return productId;
    }

    public void setProductId(long productId) {
        this.productId = productId;
    }

    public String getTransactionId() {
        return transactionId;
    }

    public void setTransactionId(String transactionId) {
        this.transactionId = transactionId;
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public long getPaymentId() {
        return paymentId;
    }

    public void setPaymentId(long paymentId) {
        this.paymentId = paymentId;
    }

    public String getCardLast4Digit() {
        return cardLast4Digit;
    }

    public void setCardLast4Digit(String cardLast4Digit) {
        this.cardLast4Digit = cardLast4Digit;
    }

    public long getNetworkId() {
        return networkId;
    }

    public void setNetworkId(long networkId) {
        this.networkId = networkId;
    }

    public String getTransactionRef() {
        return transactionRef;
    }

    public void setTransactionRef(String transactionRef) {
        this.transactionRef = transactionRef;
    }

    public String getReceiverMsisdn() {
        return receiverMsisdn;
    }

    public void setReceiverMsisdn(String receiverMsisdn) {
        this.receiverMsisdn = receiverMsisdn;
    }
}

0 个答案:

没有答案