Spring内部bean无法通过id获取

内部Bean注入正常,但是直接在context中getBean是得不到的;

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns="http://www.springframework.org/schema/beans" xmlns:p="http://www.springframework.org/schema/p"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
    http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
    <bean id="duke" class="com.stono.sprtest.Duke">
        <property name="name" value="Elvis" />
        <property name="instrument">
            <bean id="saxophone" class="com.stono.sprtest.Saxophone"></bean>
        </property>
    </bean>
</beans>
原文地址:https://www.cnblogs.com/stono/p/4829137.html