【问题标题】:Maven avro plugin gives schema not yet supported errorMaven avro 插件给出了尚不支持模式的错误
【发布时间】:2020-08-04 00:32:11
【问题描述】:

在我的 maven 项目中,我使用 maven avro 插件从 avro 模式文件创建 Java 类。这是我从架构注册表中获得的 avro 文件。

{
   "type":"record",
   "name":"Envelope",
   "namespace":"mongodb.company.price_service_company_calc_logs",
   "fields":[
      {
         "name":"after",
         "type":[
            null,
            {
               "type":"string",
               "connect.version":1,
               "connect.name":"io.debezium.data.Json"
            }
         ],
         "default":null
      },
      {
         "name":"patch",
         "type":[
            null,
            {
               "type":"string",
               "connect.version":1,
               "connect.name":"io.debezium.data.Json"
            }
         ],
         "default":null
      },
      {
         "name":"filter",
         "type":[
            null,
            {
               "type":"string",
               "connect.version":1,
               "connect.name":"io.debezium.data.Json"
            }
         ],
         "default":null
      },
      {
         "name":"source",
         "type":{
            "type":"record",
            "name":"Source",
            "namespace":"io.debezium.connector.mongo",
            "fields":[
               {
                  "name":"version",
                  "type":"string"
               },
               {
                  "name":"connector",
                  "type":"string"
               },
               {
                  "name":"name",
                  "type":"string"
               },
               {
                  "name":"ts_ms",
                  "type":"long"
               },
               {
                  "name":"snapshot",
                  "type":[
                     {
                        "type":"string",
                        "connect.version":1,
                        "connect.parameters":{
                           "allowed":true,
                           "last":false
                        },
                        "connect.default":false,
                        "connect.name":"io.debezium.data.Enum"
                     },
                     null
                  ],
                  "default":false
               },
               {
                  "name":"db",
                  "type":"string"
               },
               {
                  "name":"rs",
                  "type":"string"
               },
               {
                  "name":"collection",
                  "type":"string"
               },
               {
                  "name":"ord",
                  "type":"int"
               },
               {
                  "name":"h",
                  "type":[
                     null,
                     "long"
                  ],
                  "default":null
               },
               {
                  "name":"tord",
                  "type":[
                     null,
                     "long"
                  ],
                  "default":null
               }
            ],
            "connect.name":"io.debezium.connector.mongo.Source"
         }
      },
      {
         "name":"op",
         "type":[
            null,
            "string"
         ],
         "default":null
      },
      {
         "name":"ts_ms",
         "type":[
            null,
            "long"
         ],
         "default":null
      }
   ],
   "connect.name":"mongodb.company.price_service_company_calc_logs.Envelope"
}

每当我运行 mvn package 时,都会出现以下错误:

目标 org.apache.avro:avro-maven-plugin:1.9.2:schema 的执行默认值失败:尚不支持架构:null

有什么方法可以让我获得有关问题确切根源的更多信息?显然 maven -e 或 -X 开关没有多大帮助。

【问题讨论】:

    标签: java mongodb maven avro


    【解决方案1】:

    原来 avro 文件不正确。类型的所有空值都必须用双引号括起来。

    {
       "type":"record",
       "name":"Envelope",
       "namespace":"mongodb.company.price_service_company_calc_logs",
       "fields":[
          {
             "name":"after",
             "type":[
                "null",
                {
                   "type":"string",
                   "connect.version":1,
                   "connect.name":"io.debezium.data.Json"
                }
             ],
             "default":null
          },
          {
             "name":"patch",
             "type":[
                "null",
                {
                   "type":"string",
                   "connect.version":1,
                   "connect.name":"io.debezium.data.Json"
                }
             ],
             "default":null
          },
          {
             "name":"filter",
             "type":[
                "null",
                {
                   "type":"string",
                   "connect.version":1,
                   "connect.name":"io.debezium.data.Json"
                }
             ],
             "default":null
          },
          {
             "name":"source",
             "type":{
                "type":"record",
                "name":"Source",
                "namespace":"io.debezium.connector.mongo",
                "fields":[
                   {
                      "name":"version",
                      "type":"string"
                   },
                   {
                      "name":"connector",
                      "type":"string"
                   },
                   {
                      "name":"name",
                      "type":"string"
                   },
                   {
                      "name":"ts_ms",
                      "type":"long"
                   },
                   {
                      "name":"snapshot",
                      "type":[
                         {
                            "type":"string",
                            "connect.version":1,
                            "connect.parameters":{
                               "allowed":true,
                               "last":false
                            },
                            "connect.default":false,
                            "connect.name":"io.debezium.data.Enum"
                         },
                         "null"
                      ],
                      "default":false
                   },
                   {
                      "name":"db",
                      "type":"string"
                   },
                   {
                      "name":"rs",
                      "type":"string"
                   },
                   {
                      "name":"collection",
                      "type":"string"
                   },
                   {
                      "name":"ord",
                      "type":"int"
                   },
                   {
                      "name":"h",
                      "type":[
                         "null",
                         "long"
                      ],
                      "default":null
                   },
                   {
                      "name":"tord",
                      "type":[
                         "null",
                         "long"
                      ],
                      "default":null
                   }
                ],
                "connect.name":"io.debezium.connector.mongo.Source"
             }
          },
          {
             "name":"op",
             "type":[
                "null",
                "string"
             ],
             "default":null
          },
          {
             "name":"ts_ms",
             "type":[
                "null",
                "long"
             ],
             "default":null
          }
       ],
       "connect.name":"mongodb.company.price_service_company_calc_logs.Envelope"
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2022-09-28
      • 2021-04-26
      • 1970-01-01
      • 2011-09-13
      • 1970-01-01
      • 2019-06-01
      • 1970-01-01
      相关资源
      最近更新 更多