Bootstrap

feign接口异常之feign.codec.DecodeException

又踩坑了之feign接口异常

feign.codec.DecodeException: Error while extracting response for type [class com.qmp.product.cyb.vo.PlayItemPackageVO] and content type [application/json]; nested exception is org.springframework.http.converter.HttpMessageNotReadableException: JSON parse error: Unexpected character ('}' (code 125)): was expecting a colon to separate field name and value; nested exception is com.fasterxml.jackson.core.JsonParseException: Unexpected character ('}' (code 125)): was expecting a colon to separate field name and value
 at [Source: (PushbackInputStream); line: 1, column: 510]

这个的原因是因为转换成json之后结果为空,导致只有key,没有value

2020-12-21 11:58:18.025 ERROR 2776 --- [nio-9003-exec-4] c.q.e.advice.ExceptionHandlerAdvice      : Could not write JSON: Can not write a field name, expecting a value; nested exception is com.fasterxml.jackson.core.JsonGenerationException: Can not write a field name, expecting a value

org.springframework.http.converter.HttpMessageNotWritableException: Could not write JSON: Can not write a field name, expecting a value; 

最终原因都是使用了时间戳,需要将其转为Date类型,然后在被调用方法中将
将PO的Timestamp或者LocalDateTime转为Date类型即可避免此问题

package com.qmp.product.cyb.vo;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.validation.constraints.NotNull;
import java.math.BigDecimal;
import java.sql.Date;
import java.sql.Timestamp;
import java.time.LocalDateTime;

/**
 * 项目套餐表
 * @author 刘
 * @since 2020-12-11
 */
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class PlayItemPackageVO {
    /**
     * 景区id
     */
    private Long organizationId;

    /**
     * 创建时间 问题的最终原因点Timestamp
     */
    private Timestamp createTime;

    /** 
     * 修改时间 问题的最终原因点Timestamp
     */
    private Timestamp modifyTime;

    /**
     * 修改者
     */
    private Long modifierId;

    /**
     * 创建者
     */
    private Long creatorId;

    /**
     * 部门
     */
    private String department;

}

;