r/SpringBoot • • Apr 28 '26

Question Question about dependency injection

How do I manually inject dependencies into RequestController classes? I just started learning spring and from my bit of research, all I've come up with is the Autowired and Component/Service annotations.

I am still having a hard time understanding how exactly I tell spring what to build. If the dependency of my controller needs dependencies injected into it, what do I do? How do I specify which implementation of a dependency I want built? And so on.

Essentially, how do I get a bit more control of dependency creation and injection in a non-trivial situation, like the ones seen in examples on the internet?

Thanks in advance for any responses.

17 Upvotes

25 comments sorted by

View all comments

Show parent comment

0

u/boost2525 Apr 28 '26

Downvote for Lombok, but otherwise I'm agreement with you. Lombok has out stayed it's welcome and has no place in a spring boot 4 / JRE 17+ world.

1

u/Character-Grocery873 Apr 29 '26

Why? I still find it very useful like getters/setters for a pojo which Cant be a record. Also @RequiredArgsCons aswell is still useful and it's other annotations.

1

u/locusleman Apr 29 '26

Why man? Constructor injection is fastest using @RequiredArgsConstructor form Lombok. What's wrong with it? Can you please elaborate, I am in learning curve also.

1

u/Substantial_Ad252 Apr 29 '26

why? i love lombok and used it in every project i worked on.
@/RequiredArgsConstructor all over the place and @/Data extensively aswell.

what problems do you see with lombok?