I have a problem with generating classes from avsc files. In the pom.xml I added the appropriate dependencies:
<dependencies>
<dependency>
<groupId>org.apache.avro</groupId>
<artifactId>avro</artifactId>
<version>1.10.2</version>
</dependency>
<dependency>
<groupId>org.apache.avro</groupId>
<artifactId>avro-compiler</artifactId>
<version>1.10.2</version>
</dependency>
</dependencies>
In the repository package I created an avro folder where I placed the class schema with the extension .avsc.
{"type":"record",
"name":"Customer",
"namespace":"com.avroGenerator",
"fields":[
{"name":"name","type":"string"},
{"name":"age","type":"int"},
{"name":"isOfAge","type":"boolean"},
{"name":"currencies","type":
{"type":"array","items":{
"type":"record",
"name":"Currency",
"namespace":"com.avroGenerator",
"fields":[
{"name":"name","type":"string"},
{"name":"shortcut","type":"string"}]}},
"default":[]}]}
It's a customer class including array of currencies witch are also generated from avsc.
When calling Maven-> Package in target-generated-sources, I should see my class, but it doesn't. Has anyone had a similar problem?
You need to add
avro-maven-plugin
mentioned in a<plugin>
sectionhttps://avro.apache.org/docs/current/gettingstartedjava.html
You don't need
avro-compiler
as a dependency in your own code if you only want to convert schema resource files into classes