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

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.