schema文件
代码语言:javascript复制{
"namespace": "com.ric",
"type": "record",
"name": "Customer",
"fields": [
{"name": "id", "type": "int"},
{"name": "name", "type": "string"},
{"name": "email", "type": ["null", "string"], "default" : "null"},
{"name":"images","type":[{"type":"string","avro.java.string":"String"},"null"],"default":"null"}
]
}
下载avro-tools-1.8.2.jar工具,可以通过maven来下载
代码语言:javascript复制 <dependency>
<groupId>org.apache.avro</groupId>
<artifactId>avro-tools</artifactId>
<version>1.8.2</version>
</dependency>
cmd下执行如下指令,生成schema对应的entity
代码语言:javascript复制指令格式:
java -jar /path/to/avro-tools-1.8.0.jar compile schema <schema file> <destination>
最佳实践
java -jar avro-tools-1.8.2.jar compile schema Customer.avsc .