Skip to content

Delete of unnecesary Autowired - DocumentController #841

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

RustyGearBox
Copy link
Collaborator

When using constructor injection, Spring automatically injects the dependencies without requiring the @Autowired annotation. So We can safely remove it from the constructor.

@paumaneja paumaneja self-requested a review April 29, 2025 14:42
Copy link
Collaborator

@paumaneja paumaneja left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I noticed that env (lines 29-30) is still being injected using @Autowired, while the other dependencies (openApiConfig and documentService) are injected via constructor.
Since the goal of the PR is to remove @Autowired, I was wondering if there's any particular reason why env was kept this way — maybe something I'm missing?

Also, would using @requiredargsconstructor with all three fields marked as final be a viable alternative here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants