How can I use Lombok in conjunction with my @XmlElement
tags so that I can unmarshall the object?
I have about 20 properties, so I'm looking to not write an explicit getter and setter for each with the XmlElement
tags on the setters.
Maven dependencies for Spring Boot and LombokFollowing dependencies are used to work with Spring Boot and Lombok and for testing Spring components. Make sure you already installed lombok setup for your IDE. To Setup in Eclipse or in Spring Tool Suite refer to our Lombok Maven example setup with Eclipse.
Lombok Dependency Note: If you're using a Spring Boot POM, Project Lombok is a curated dependency. Thus, you can omit the version (which will then be inherited from the Spring Boot parent POM).
It does not decrease performance at runtime, there is a performance flaw at compiletime.
@Data is a convenient shortcut annotation that bundles the features of @ToString , @EqualsAndHashCode , @Getter / @Setter and @RequiredArgsConstructor together: In other words, @Data generates all the boilerplate that is normally associated with simple POJOs (Plain Old Java Objects) and beans: getters for all fields, ...
This gets the job done:
@Data
@XmlRootElement(name = "root")
@XmlAccessorType(XmlAccessType.FIELD) // UPDATE: Need this or else exception
public class Data {
@XmlElement(name = "test")
public double testData;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With