AVRO Java 生成器 - 日期生成为 int
AVRO Java generator - Dates generated as int
我正在使用 maven 插件 avro-maven-plugin (1.9.2) 从 AVRO-schema-file (avsc) 生成 Java 类。我正在定义一个日期字段,如下所示:
{
"name": "inceptionDate",
"type": "int",
"logicalType": "date"
}
我面临的问题是,它生成 int 而不是 Date 或 LocalDate。
private int inceptionDate;
pom.xml配置定义如下:
<plugin>
<groupId>org.apache.avro</groupId>
<artifactId>avro-maven-plugin</artifactId>
<version>1.9.2</version>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>schema</goal>
</goals>
<configuration>
<dateTimeLogicalTypeImplementation>JSR310</dateTimeLogicalTypeImplementation>
<sourceDirectory>${project.basedir}/src/main/resources/schema/</sourceDirectory>
<outputDirectory>${project.build.directory}/generated-sources/main/java/</outputDirectory>
<stringType>String</stringType>
<fieldVisibility>PRIVATE</fieldVisibility>
</configuration>
</execution>
</executions>
</plugin>
有什么想法,怎么了?
您应该按如下方式定义日期字段:
{
"name": "inceptionDate",
"type": {
"type": "int",
"logicalType": "date"
}
}
我正在使用 maven 插件 avro-maven-plugin (1.9.2) 从 AVRO-schema-file (avsc) 生成 Java 类。我正在定义一个日期字段,如下所示:
{
"name": "inceptionDate",
"type": "int",
"logicalType": "date"
}
我面临的问题是,它生成 int 而不是 Date 或 LocalDate。
private int inceptionDate;
pom.xml配置定义如下:
<plugin>
<groupId>org.apache.avro</groupId>
<artifactId>avro-maven-plugin</artifactId>
<version>1.9.2</version>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>schema</goal>
</goals>
<configuration>
<dateTimeLogicalTypeImplementation>JSR310</dateTimeLogicalTypeImplementation>
<sourceDirectory>${project.basedir}/src/main/resources/schema/</sourceDirectory>
<outputDirectory>${project.build.directory}/generated-sources/main/java/</outputDirectory>
<stringType>String</stringType>
<fieldVisibility>PRIVATE</fieldVisibility>
</configuration>
</execution>
</executions>
</plugin>
有什么想法,怎么了?
您应该按如下方式定义日期字段:
{
"name": "inceptionDate",
"type": {
"type": "int",
"logicalType": "date"
}
}