spring : No bean named 'xxxx' is defined
异常如下:
org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'propertyPlaceHolder' is defined
我的spring的application.xml的配置如下:
<!-- 定义受环境影响易变的变量 -->
<bean id="propertyPlaceHolder" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="systemPropertiesModeName" value="SYSTEM_PROPERTIES_MODE_OVERRIDE" />
<property name="ignoreResourceNotFound" value="true" />
<property name="locations">
<list>
<value>classpath:config/dev/schedule.xml</value>
</list>
</property>
</bean>
下面为demo运行代码:
String[] path = {"classpath:config/dev/schedule.xml"};
ClassPathXmlApplicationContext wapp = new ClassPathXmlApplicationContext(path);
PropertyPlaceholderConfigurer configure = (PropertyPlaceholderConfigurer) wapp.getBean("propertyPlaceHolder");
这个“propertyPlaceHolder” 已经在application.xml中注册了啊?这到底是为什么?我把同样的配置和代码给别人,别人就能够得到PropertyPlaceholderConfigurer 对象。
另: schedule.xml里面配置的数据源,项目启动无异常,数据正常访问,这说明这个schedule.xml是正常获取读取访问的。
所以现在很困惑为什么会是is not defined。
求各位大佬不吝赐教。谢谢!