在依賴AI有以下使用Spring配置文件:如何在Maven的依賴
<beans>
<bean
id="simplePersonBase"
class="com.paml.test.SimplePerson"
abstract="true">
<property
name="firstName"
value="Joe" />
<property
name="lastName"
value="Smith" />
</bean>
</beans>
然後在項目B,我添加了一個作爲一個依賴,並具有以下配置:
<?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
id="simplePersonAddress01"
parent="simplePersonBase">
<property
name="firstName"
value="BillyBob" />
<property
name="address"
value="1060 W. Addison St" />
<property
name="city"
value="Chicago" />
<property
name="state"
value="IL" />
<property
name="zip"
value="60613" />
</bean>
</beans>
當我使用的ClassPathXmlApplicationContext像這樣:
BeanFactory beanFactory = new ClassPathXmlApplicationContext(new String[] {
"./*.xml" });
SimplePerson person = (SimplePerson)beanFactory.getBean("simplePersonAddress01");
System.out.println(person.getFirstName());
春抱怨,因爲它不能解析的XML父。
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'simplePersonBase' is defined
我確信有一種方法可以做到這一點,但是我沒有找到它。有誰知道如何?
的的src/main /資源我以前看到這一點,但另一個錯誤是誤導我。根據記錄,這是我有什麼改變時: \t \t Bean工廠的beanfactory =新的ClassPathXmlApplicationContext(新的String [] { \t \t \t 「的classpath *:* XML」}); – javamonkey79 2010-04-15 18:54:21