Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Bean from another application context to be referred in my application context

 
Swathi Kodeboyina
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have two application context files. I want to refer a bean in first application context in the second application context. When I do this, I am getting a NoSuchBeanDefintionException.

How do I go about it?
 
Bill Gorder
Bartender
Posts: 1682
7
Android IntelliJ IDE Linux Mac OS X Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Depends on the relationship between your contexts. If there is a parent child relationship that the child can see the parent but not vice versa. Assuming the beans are in the same context (not the same as the same .xml file) then you should be able to just use



from the reference docs

Specifying the target bean through the bean attribute of the <ref/> tag is the most general form, and
allows creation of a reference to any bean in the same container or parent container, regardless of whether
it is in the same XML file. The value of the bean attribute may be the same as the id attribute of the
target bean, or as one of the values in the name attribute of the target bean.


Alternatively if your second second application context is just a new file you created to split things up you will need to import it.
 
deepu sharma
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what exact requirement do you want? you want to refer bean in two applicaton contexts?
or one by one you wanna refer?
and also send full stack trace?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic