Questions tagged [lombok]

Project Lombok is a tool for reducing boilerplate code in Java through annotations and compile time code generation.

The details for project Lombok can be found at http://projectlombok.org/.

The primary functionality of Lombok is reducing the boilerplate code in JavaBeans by replacing all setters, getters, equals, hashCode and toString with a single @Data annotation on the class.

Many other useful features are offered and the project is under active development.

2384 questions
469
votes
14 answers

Is it safe to use Project Lombok?

In case you don't know Project Lombok helps with some of the annoyances of Java with stuff like generating getters and setters with annotations and even simple JavaBean like generation with @Data. It could really help me, especially in 50 different…
TheLQ
  • 14,830
  • 14
  • 69
  • 107
390
votes
2 answers

Omitting one Setter/Getter in Lombok

I want to use a data class in Lombok. Since it has about a dozen fields, I annotated it with @Data in order to generate all the setters and getter. However there is one special field for which I don't want to the accessors to be implemented. How…
DerMike
  • 15,594
  • 13
  • 50
  • 63
277
votes
45 answers

Can't compile project when I'm using Lombok under IntelliJ IDEA

I'm trying to use Lombok in my project that I'm developing using IntelliJ IDEA 11. I've installed 3rd-party plugin for IDEA and it seems working fine because IDEA sees all autogenerated methods/fields. So I have a class that uses Slf4j. I annotated…
expert
  • 29,290
  • 30
  • 110
  • 214
264
votes
11 answers

Lombok annotations do not compile under Intellij idea

I've installed the plugin for intellij idea(lombok-plugin-0.8.6-13). Added lombok.jar into classpath I can find getters and setters in the window of structure. And Intellij shows no error. Setting - Lombok plugin - Verified Intellij configuration…
yurnom
  • 2,641
  • 2
  • 12
  • 4
220
votes
3 answers

Build an object from an existing one using lombok

Lets say I have a Lombok annotated class like @Builder class Band { String name; String type; } I know I can do: Band rollingStones = Band.builder() .name("Rolling Stones") .type("Rock Band") .build(); Is there an easy way to…
Mustafa
  • 5,624
  • 3
  • 24
  • 40
199
votes
6 answers

how to Call super constructor in Lombok

I have a class @Value @NonFinal public class A { int x; int y; } I have another class B @Value public class B extends A { int z; } lombok is throwing error saying it cant find A() constructor, explicitly call it what i want lombok to…
Sandeep Nagaraj
  • 2,122
  • 2
  • 12
  • 10
191
votes
22 answers

Lombok added but getters and setters not recognized in Intellij IDEA

I am using IntelliJ IDEA on ubuntu. I added lombok.jar into my project and installed the Lombok plugin for IDEA. I have access to the annotations but the getters and setters aren't generated. I get the same errors I would get if I tried accessing a…
Don Quixote
  • 4,120
  • 3
  • 16
  • 27
190
votes
3 answers

java.lang.IllegalAccessError: class lombok.javac.apt.LombokProcessor cannot access class com.sun.tools.javac.processing.JavacProcessingEnvironment

I am somewhat new to coding and am trying to use the Lombok plugin to automatically create Getters/Setters e.t.c. for my fields of a specific class. In doing so I get greeted with the following error: The error: java: java.lang.IllegalAccessError:…
Dainank
  • 2,142
  • 2
  • 7
  • 14
189
votes
4 answers

How does lombok work?

I met lombok today. I'm very anxious to know how it works. A Java Geek Article gives some clues but it's not perfectly clear to me: Java 6 removes apt and make javac able to manage annotations, streamlining the process to obtain a simpler …
uuidcode
  • 3,790
  • 3
  • 25
  • 30
182
votes
21 answers

MapStruct + Lombok together not compiling: unknown property in result type

Tech Stack being used : Java 8 MapStruct : 1.2.0.Final Lombok: 1.16.18 IDE: IntelliJ - Lombok Plugin already installed Initially, I faced issues when I removed getters and setters and added @Getter and @Setter annotation, mapstruct is not able to…
Vivek Gupta
  • 2,534
  • 3
  • 15
  • 28
172
votes
37 answers

Building with Lombok's @Slf4j and Intellij: Cannot find symbol log

I have a maven project that builds with no problems from the command line. However, when I build it with IntelliJ, I get the error: java: FileName.java:89: cannot find symbol symbol : variable log There is no log defined or imported in the java…
user1991839
  • 1,993
  • 2
  • 14
  • 11
170
votes
7 answers

Java Lombok: Omitting one field in @AllArgsConstructor?

If I specify @AllArgsConstructor using Lombok, it will generate a constructor for setting all the declared (not final, not static) fields. Is it possible to omit some field and this leave generated constructor for all other fields?
user3656823
  • 1,703
  • 2
  • 10
  • 4
160
votes
25 answers

Lombok is not generating getter and setter

I just tried to send a Maven-based project to another computer and HORROR, red markers everywhere!! However, mvn clean install is building just fine. Quickly, I noticed that Lombok is not generating getters and setters for my classes, although the…
Heetola
  • 5,791
  • 7
  • 30
  • 45
145
votes
4 answers

Warning equals/hashCode on @Data annotation lombok with inheritance

I have a entity which inherits from other. On other hand, I'm using lombok project to reduce boilerplate code, so I put @Data annotation. The annotation @Data with inheritance produces the next warning: Generating equals/hashCode implementation but…
Pau
  • 14,917
  • 14
  • 67
  • 94
140
votes
21 answers

Can't make Jackson and Lombok work together

I am experimenting in combining Jackson and Lombok. Those are my classes: package testelombok; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.AllArgsConstructor; import…
1
2 3
99 100