I am generating Java classes from AVSC file using the avro-maven-plugin
and I want to add annotation @JsonProperty
on the variable name.
I want to understand how I can do that the record.vm file in the configuration does mention of a tag javaAnnotation
but it does not work as expected.
Pom.xml
<plugin>
<groupId>org.apache.avro</groupId>
<artifactId>avro-maven-plugin</artifactId>
<version>${avro.version}</version>
<dependencies>
...
</dependencies>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>schema</goal>
</goals>
<configuration>
<fieldVisibility>PRIVATE</fieldVisibility>
<enableDecimalLogicalType>true</enableDecimalLogicalType>
<stringType>String</stringType>
<templateDirectory>/com/.../avro/compiler/specific/templates/</templateDirectory>
<dateTimeLogicalTypeImplementation>joda</dateTimeLogicalTypeImplementation>
</configuration>
</execution>
</executions>
Snipit from record.vm
I want the generated class to look like this
I tried something like this but it did not work
[{
"namespace": "com..avro",
"type": "record",
"name": "myClass",
"fields": [
{
"name": "my_variable",
"type": "int",
"javaAnnotations":"com.fasterxml.jackson.annotation.JsonProperty("my_variable")",
"javaAnnotations":[
"com.fasterxml.jackson.annotation.JsonProperty("my_variable")"
]
}
]
}]