Skip to content
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

Replace SpringContext.getBean() with Dependency Injection #1062

Open
konavivekramakrishna opened this issue Jun 3, 2024 · 6 comments
Open

Comments

@konavivekramakrishna
Copy link
Contributor

konavivekramakrishna commented Jun 3, 2024

Refactor the code to replace SpringContext.getBean() with constructor or setter injection in all Spring-managed beans to improve best practices and maintainability.

@rahul6603
Copy link
Contributor

Thank you @konavivekramakrishna for creating this issue.
I agree with the suggested changes. On a similar note, we should also consider replacing usages of SpringContext.getBean() with constructor-based injection wherever possible in our codebase.
I will help to review and implement these changes if needed.

@mozzy11
Copy link
Collaborator

mozzy11 commented Jun 3, 2024

@konavivekramakrishna it may make testing a bit easire but it will make the code less readable and more Verbose.

@konavivekramakrishna
Copy link
Contributor Author

Then as @rahul6603 said should we consider replacing the usage SpringContext.getBean() and modify this issue, @mozzy11 ?

@mozzy11
Copy link
Collaborator

mozzy11 commented Jun 3, 2024

SpringContext.getBean() is used mostly in non beans , ie Classes not handled by Spring.

we can replace it in all Spring beans

@konavivekramakrishna konavivekramakrishna changed the title Remove usage of Field Injections Replace SpringContext.getBean() with Dependency Injection Jun 5, 2024
@Dheerajr444
Copy link

can I work on this issue @mozzy11, @konavivekramakrishna

@rahul6603
Copy link
Contributor

Sure @Dheerajr444 , go ahead.

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

No branches or pull requests

4 participants