Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Java config: could not autowired a List.

 
H Paul
Ranch Hand
Posts: 471
4
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1682
7
Android IntelliJ IDE Linux Mac OS X Spring
  • 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@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.
 
H Paul
Ranch Hand
Posts: 471
4
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Thanks for your @ResourceFullness. It worked. (Should we create this new tag?)
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic