| Author |
Java config: could not autowired a List.
|
H Paul
Ranch Hand
Joined: Jul 26, 2011
Posts: 299
|
|
With code 1: using Java config.
The autowired is working for restTemplate.
The autowired is NOT working for thirdpartyServices
The log show ThirdpartyServiceConfiguration constructor get called.
The log show getRestTemplate get called.
The log did not show getThirdpartyServices get called.
What do I miss?
|
 |
Bill Gorder
Bartender
Joined: Mar 07, 2010
Posts: 1282
|
|
@Autowired works differently for collections. It would work if for example you did this
In this case your List would contain 2 beans of type ThirdParty service one with a name instance1 and one instance2. Basically what it does is scan the context for dependencies of that type and adds them to the collection.
If you want to do what you are doing you should use the @Resource annotation on your list.
|
[How To Ask Questions][Read before you PM me]
|
 |
H Paul
Ranch Hand
Joined: Jul 26, 2011
Posts: 299
|
|
Thanks for your @ResourceFullness. It worked. (Should we create this new tag?)
|
 |
 |
|
|
subject: Java config: could not autowired a List.
|
|
|