AVRO Java generator - Dates generated as int

Weso :

I'm using the maven plugin avro-maven-plugin (1.9.2) to generate Java classes from an AVRO-schema-file (avsc). I'm defining a date field as follows:

{
  "name": "inceptionDate",
  "type": "int",
  "logicalType": "date"
}

The problem I'm facing is, that it generates an int instead of a Date or LocalDate.

private int inceptionDate;

The pom.xml configuration is defined as follows:

  <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>

Any ideas, what's wrong?

gcallea :

You should define the date field as follow:

{
  "name": "inceptionDate",
  "type": {
    "type": "int",
    "logicalType": "date"
  }
}

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=12494&siteId=1