从 Azure Blob 读取 JSON 文件

问题描述 投票:0回答:0

我正在编写一个函数来读取 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;

    }

}
spring spring-boot azure azure-blob-storage blob
© www.soinside.com 2019 - 2024. All rights reserved.