我正在编写一个函数来读取 JSON 文件 (
name
),但是应用程序抛出以下错误:
Cannot construct instance of `File` (no Creators, like default constructor, exist): cannot deserialize from Object value (no delegate- or property-based Creator)
我在
MyResponse.java
中添加了创建默认构造函数所需的所有注释,但仍然出现相同的错误。我做错了什么?
public MyResponse getBlobData(String name) {
MyResponse myResponse = myResponse.builder().build();
try {
CloudBlob cloudBlob = muContainer.getBlobReferenceFromServer(name);
InputStream input = cloudBlob.openInputStream();
InputStreamReader inr;
try {
inr = new InputStreamReader(input, "UTF-8");
myResponse = mapper.readValue(IOUtils.toString(inr), myResponse.class);
} catch (Exception e) {
log.error("Unable to read file from Azure blob {}," e.getMessage());
}
} catch (URISyntaxException | StorageException e) {
log.error("Unable to read file from Azure blob {}", e.getMessage());
}
return detourResponse;
}
编辑: MyResponse 类
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
@JsonAutoDetect
public class MyResponse {
@JsonProperty("provider")
public Map<String, String> provider;
@JsonProperty("data")
@JsonInclude(JsonInclude.Include.NON_EMPTY)
public List<myData> myData;
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
public static class myData {
@JsonProperty("my_id")
public String myId;
@JsonProperty("title")
public String title;
@JsonProperty("days")
public List<Day> days;
}
}