在依赖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