This week's book giveaway is in the OCAJP forum.
We're giving away four copies of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) and have Khalid A Mughal & Rolf W Rasmussen on-line!
See this thread for details.
Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Can we pass a dynamic list of ref-beans to a bean in spring application context file?

 
Santosh Kavadimatti
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I am new to spring. I am facing a problem and don't know how to tackle it.
Here is the issue:

I have a spring application context file - spring-application-context-XXX.xml
And i have a bean named,say "aBean" defined like dis :
<bean id="aBean" class="com.some.package.SomeClass" >
Now, I need to pass a list of ref-beans to this bean via setter injection.
The ref-beans have to be presented in some other spring application context file (say, spring-application-context-YYY.xml, which will be included in spring-application-context-XXX.xml via <import resource=""/>.
The number of beans should be dynamic (i.e they can be 3 or 4 or any in number).

Is there any way we can achieve this?

Thanks in advance for suggestions!
 
Vyas Sanzgiri
Ranch Hand
Posts: 686
Chrome Netbeans IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try @Autowired(required=false)
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic