File tree Expand file tree Collapse file tree
java-checks/src/main/resources/org/sonar/l10n/java/rules/java Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11< h2 > Why is this an issue?</ h2 >
2- < p > Spring supports dependency injection by using annotations such as < code > @Autowired </ code > . This annotation can be used to inject beans via
3- constructor, setter, and field injection.</ p >
2+ < p > Dependency injection frameworks such as Spring support dependency injection by using annotations such as < code > @Inject </ code > and
3+ < code > @Autowired </ code > . These annotation can be used to inject beans via constructor, setter, and field injection.</ p >
44< p > Generally speaking, field injection is discouraged. It allows the creation of objects in an invalid state and makes testing more difficult. The
55dependencies are not explicit when instantiating a class that uses field injection.</ p >
66< p > Apart from that, field injection is not compatible with final fields. Keeping dependencies immutable where possible makes the code easier to
You can’t perform that action at this time.
0 commit comments