Search code examples
javaspringspring-bootspring-mvclombok

Should I use the lombok library in Springboot?


Should I use the lombok library in Java Springboot? Some youtube publishers say that it is not correct to use the lombok library. what do you think about this issue?

I used Lombok in a few of my projects and it was very useful, but I hesitate whether to use it in hine or not. If I shouldn't use it, what should I use instead of lombok?


Solution

  • There is no technical problem with Lombok at all. The whole discussion is actually about a design issue. With Lombok some developers tend to use the getter/setter auto generation for every single class. For pure DTO classes that just represent a data structure, this might be ok. But since Java 16/17 there are record classes for that. For other classes that encapsulate an actual state and behavior (state transitions beyond simple setters through accessor methods) you might accidentally open attributes with getters/setters that shouldn't be accessed from the outside. So it is up to you - sometimes it is helpful and sometimes not that much.