0

i have my field like that

@Autowired
private QualiteRepo qualiteRepo;
@Autowired
private FonctionRepo fonctionRepo;
@Autowired
private DomaineRepo domaineRepo;
@Autowired
private DivisionRepo divisionRepo;
[...]

Can i regroup them by using @Autowired just one time ? i try this but it didn't work :

@Autowired
private QualiteRepo qualiteRepo;
private FonctionRepo fonctionRepo;
private DomaineRepo domaineRepo;
private DivisionRepo divisionRepo;
[...]
Hayi
  • 6,972
  • 26
  • 80
  • 139
  • 1
    Youssef, as described it's not possible to implement in java because the fields of the class are not ordered http://stackoverflow.com/questions/1097807/java-reflection-is-the-order-of-class-fields-and-methods-standardized – Boris Treukhov Jan 22 '14 at 15:49
  • 1
    You can still inject several the fields via setter method (marked with `@Autowired`) that takes several arguments or via constructor injection though. – Boris Treukhov Jan 22 '14 at 15:55

1 Answers1

2

This is not supported in Spring. So you can not do that.

Why would you want some thing like that?

There is an obvious cause not to support this, if you do not want, any one of them to be autowired?

Sazzadur Rahaman
  • 6,938
  • 1
  • 30
  • 52