AVRO Java生成器-日期生成为int
我使用maven插件avro-maven插件1.9.2从avro模式文件avsc生成Java类。我定义了一个日期字段,如下所示:AVRO Java生成器-日期生成为int,java,java-8,apache-kafka,avro,avro-tools,Java,Java 8,Apache Kafka,Avro,Avro Tools,我使用maven插件avro-maven插件1.9.2从avro模式文件avsc生成Java类。我定义了一个日期字段,如下所示: { "name": "inceptionDate", "type": "int", "logicalType": "date" } <plugin> <groupId>org.apache.avro</groupId> <artifactId>avro-maven-plugin</
{
"name": "inceptionDate",
"type": "int",
"logicalType": "date"
}
<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>
我面临的问题是,它生成的是int而不是Date或LocalDate
pom.xml配置定义如下:
{
"name": "inceptionDate",
"type": "int",
"logicalType": "date"
}
<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"
}
}
根据它应该能够生成日期类。它在1.9.0版本中被合并并发布。这就是为什么maven插件中有一个配置选项dateTimeLogicalTypeImplementation。困惑…你是对的。请参阅我对该问题的更新。应该行的,哇!这个有用!!啊……我怎么看不见呢。