我的应用从两个XML文件中加载Spring Bean定义:
String[] beandefs = new String[] {
"commonConfig.xml",
"specificConfig.xml"
};
ApplicationContext context = new ClassPathXmlApplicationContext(
beandefs);
这是因为
commonConfig.xml
包含我想要在所有部署中使用的定义。而specificConfig.xml
中则包含我会在测试部署中替换为其他实现的定义。这样做没有问题,但是当一个bean引用了另一个文件中的bean时,Eclipse (STS)会给它打上警告标记。
例如,如果
commonConfig.xml
包含: <bean id="foo" class="com.example.Foo">
<property name="bar" ref="bar" />
</bean>
...并且specificConfig.xml
包含:
<bean id="bar" class="com.example.Bar">
...
</bean>
这个应用程序工作得很好,但是Eclipse在commonConfig.xml
中发出了警告:
Referenced bean 'bar' not found.
我该如何告诉Eclipse在两个文件中查找?