Announcement Announcement Module
Collapse
No announcement yet.
nested bean access via .getBean(name) Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    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.

    Comment

    Working...
    X