I am working on jaxb2-maven-plugin, I am generating Java POJOs from XSD.
I need to add @Data annotation on top of the class without setters getters.
The output file should look like this.
@Data
public class Employee {
@JsonProperty("name")
private Name name;
@JsonProperty("joindate")
private String joindate;
@JsonProperty("payload")
private String payload;
}
My XSD is like this
<?xml version="1.0" encoding="utf-8"?>
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="employee">
<xs:complexType>
<xs:sequence>
<xs:element name="name">
<xs:complexType>
<xs:sequence>
<xs:element name="lastname" type="xs:string" />
<xs:element name="firstname" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="hiredate" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
I need to add annotation on Name.java as well. I have around 100 XSDs. I need to do this for all XSDs
Yes you can do that, by adding 3rd party plugins for jaxb generating, for example, https://github.com/svzdvd/jaxb-lombok-plugin
Then the generated class will have the lombok annotations as you want. there are couple of others similar plugins more or less doing the same thing, check them:
https://jitpack.io/p/wwerner/jaxb-lombok-plugin
https://github.com/mplushnikov/xjc-lombok-plugin