How to make Lombok copy @Qualifier on generated constructors for a Spring Component/Service
In the previous part of my blogpost I mentioned that it is now possible to actually add @Qualifier to a field in Spring-wired class and it’d be properly wired. Without further ado:
Lombok already copies some specific annotations like
CheckForNull but now you can tweak that by appending to the list of annotations you want lombok to copy to the constructor.
One of them, of course, being the
I hope this helps you guys into writing cleaner, better, more idiomatic Java code. Happy coding!
As I feel instrumental to this feature, here is a little backstory:
Back in 2015 we saw this feature is the only thing preventing us from writing clear, idiomatic @RequiredArgsConstructor code in all our repos. Luckily, the same question has already been asked on StackOverflow and a ticket existed in lombok. However, in the beginning, it was more of a question and less of a feature, I felt like I needed to (like in my teenage years) get things in my own hands (yes, I make this kind of jokes…):
That’s where the beauty of the crowd and open source projects lies in; gain enough traction, and you can deeply influence a project! Many many thanks to Roel Spilker @rspilker from Lombok for implementing my suggestion and I hope we’ve made it easier for all the community to write (and read) cleaner code!