Results 1 to 2 of 2

Thread: nested bean access via .getBean(name)

  1. #1

    Default nested bean access via .getBean(name)

    I've been wondering this for a while...if i have a nested bean with an id attribute, why can't I look up the nested bean by the id?


    Code:
    <bean id="myParent" class="x.y.z.Parent">
       <property name="mybean">
           <bean id="myChild" class="java.lang.Object"/>
       </property>
    </bean>
    
    context.getBean("myChild") throws BeanNotFoundException

  2. #2
    Join Date
    Sep 2012
    Location
    Czech Republic
    Posts
    39

    Default

    Hi, this is just how it is meant to be, access to inner beans is limited to the scope of its encapsulating bean. The reference says: Note that the singleton flag and any id attribute are effectively ignored. Inner beans are anonymous prototypes.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •