首页 > 解决方案 > Apache Avro UnresolvedUnionException: Not in union ["null",{"type":"int","logicalType":"date"}]: 2001-01-01

问题描述

尽管在这里和那里收集了示例,但我无法为我的(lomboked)类生成正确的Avro 1.9.1模式,在我的 LocalDate 字段的序列化时获取标题的错误消息。有人可以解释我错过了什么吗?

@Data
public class Person {
    private Long id;
    private String firstname;
    private LocalDate birth;
    private Integer votes = 0;
}

这是架构:

{
"type": "record",
"name": "Person",
"namespace": "com.example.demo",
"fields": [
{
    "name": "id",
    "type": "long"
},
{
    "name": "firstname",
    "type": "string"
},
{
    "name": "birth",
    "type": [ "null", { "type": "int", "logicalType": "date" }]
},
{
    "name": "votes",
    "type": "int"
}]
}

错误,意思是在联合的“索引命名”映射中找不到 java.time.LocalDate,是这样的:org.apache.avro.UnresolvedUnionException: Not in union ["null",{"type":"int","逻辑类型“:”日期“}]:2001-01-01

索引命名的映射键是“null”和“int”,这似乎是合乎逻辑的。

标签: avrospring-cloud-stream

解决方案


推荐阅读