Spring 引导:无法将 Int 序列化为浮点型



我正在使用现成的杰克逊-databind 序列化程序将整数字段作为浮点数返回:

@XmlElement(name = "toPick")
@Column(name = "to_pick")
@JsonSerialize(using = FloatSerializer.class)
private Integer toPick;

但是我在序列化期间收到此消息:

无法写入内容:java.lang.Integer 无法转换为 java.lang.Float

也许使用 IntegerSerializer?

@XmlElement(name = "toPick")
@Column(name = "to_pick")
@JsonSerialize(using = IntegerSerializer.class)
private Integer toPick;

最新更新