有一个 POJO:
@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
@ToString
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonPropertyOrder({"uid", "access", "name", "image", "imageFilename", "index", "parent", "coefficient", "geojson",
"creationDate", "createdBy", "modifiedDate", "modifiedBy", "scaleDistance", "scalePoints", "center"})
@Entity
@Table(name = "floor")
public class Floor {
@Id
@JsonProperty("uid")
private Double uid;
@JsonProperty("access")
private Access access;
@JsonProperty("name")
private String name;
@JsonProperty("image")
private String image;
@JsonProperty("imageFilename")
private String imageFilename;
@JsonProperty("index")
private String index;
@JsonProperty("parent")
@JsonPropertyDescription("UID of the venue, where floor located")
private Double parent;
@JsonProperty("coefficient")
private Double coefficient;
@JsonProperty("geojson")
@JsonPropertyDescription("Floor polygon in GeoJSON format")
@OneToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY, optional = false)
private Point geojson;
@JsonProperty("creationDate")
private Date creationDate;
@JsonProperty("createdBy")
@JsonPropertyDescription("UID of the user")
private Double createdBy;
@JsonProperty("modifiedDate")
private Date modifiedDate;
@JsonProperty("modifiedBy")
@JsonPropertyDescription("UID of the user")
private Double modifiedBy;
@JsonProperty("scaleDistance")
private Double scaleDistance;
@JsonProperty("scalePoints")
@JsonPropertyDescription("Measurement line in GeoJSON format")
@OneToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY, optional = false)
private Point scalePoints;
@JsonProperty("center")
@JsonPropertyDescription("floor center for map rendering")
@OneToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY, optional = false)
private Center center;
}
我从 webClient 获得一个用于 pojo 的对象:
Mono<Floor> mono= webClient.get()
.uri("https://leantegra.leantegra.com/api/locations/floors")
.attributes(ServerOAuth2AuthorizedClientExchangeFilterFunction.clientRegistrationId("authProvider"))
.retrieve().bodyToMono(Floor.class);
Floor flour = mono.block()
弹出一个错误:
引起:org.springframework.core.codec.DecodingException:JSON解码错误:无法反序列
com.model.Floor化START_ARRAY令牌的实例;嵌套异常是 com.fasterxml.jackson.databind.exc.MismatchedInputException:无法反序列com.model.Floor化 START_ARRAY 标记的实例
我们在谈论什么 START_ARRAY?如何找到错误在哪里?
折腾了半天,直到在这里写了一个问题。然后我意识到了问题并重写了: