Java Lombok: Omitting one field in @AllArgsConstructor?
Solution 1:
No that is not possible. There is a feature request to create a @SomeArgsConstructor
where you can specify a list of involved fields.
Full disclosure: I am one of the core Project Lombok developers.
Solution 2:
Alternatively, you could use @RequiredArgsConstructor
. This adds a constructor for all fields that are either @NonNull
or final
.
See the documentation
Solution 3:
A good way to go around it in some cases would be to use the @Builder