Spring在context.getBean()方法中我通过类型访问没有问题,但是通过id访问就会报异常 xml配置文件如下 <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"> <bean xml:id="emp" class="po.Employee"> <property name="name" value="Z_H"></property> <property name="sex" value="男"></property> <property name="department"> <bean xml:id="dept" class="po.Department"> <property name="dept" value="中国年过"></property> </bean> </property> </bean> </beans>
通过id获取结果如下,报错了,但是我id确认过了,没有写错
通过类类型访问如下,没有问题