How to use Lombok with Maven? First, you’ll need to add the Lombok Maven dependency to your pom.xml
file. Here is an example of how you might do this:
<dependencies>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.12</version>
<scope>provided</scope>
</dependency>
</dependencies>
Once you have added the Lombok dependency to your pom.xml
file, you can use the Lombok annotations in your Java code. For example, you can use the @Data
annotation to automatically generate getters and setters for your class:
import lombok.Data;
@Data
public class User {
private String name;
private int age;
}
When you compile your code, the Lombok library will generate the getters and setters for the User
class automatically. You can then use these methods to access and modify the name
and age
properties of a User
object.