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

Make @Autowired optional on a single constructor of a class decorated with @Component [SPR-12278] #16883

Closed
spring-projects-issues opened this issue Oct 1, 2014 · 0 comments
Assignees
Labels
in: core Issues in core modules (aop, beans, core, context, expression) type: enhancement A general enhancement
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

spring-projects-issues commented Oct 1, 2014

Hans Desmet opened SPR-12278 and commented

When a class is decorated with @Compoment,
or a more specialized annotation (@Controller, @Service, ...)
and this class has only one constructor,
the use of @Autowired on this constructor can be made optional:
Spring has only one way to instantiate a bean of this class: using this constructor and injecting beans and/of values in the parameter of this constructor.

This woudl make the class more simple and 'Pojo'.

You find a lot of these classes in Spring Pet Clinic and Spring Sagan.


Affects: 4.1 GA

Issue Links:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core Issues in core modules (aop, beans, core, context, expression) type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

2 participants