这几天在学习spring,在第一次搭建自己的配置环境后,运行helloworld,结果却报了个这样的错误
Exception in thread "main" org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from file [D:\javaPro\Spring_Intro\src\1.xml]; nested exception is java.io.FileNotFoundException: null (系统找不到指定的文件。)
于是各种百度,都说是xml文件没有放置在src目录下引起的,各位也看出来了,我的文件就是放置在src下并没有什么问题,并且加载的语句也没有问题,于是我开始了各种调试和对比,终于让我发现问题所在,就是配置文件(beans.xml),我使用的是NetBeans,并且配置文件也是由NetBeans生成的,所以最开始没有想到这上面
下面附上 正确的配置
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://www.springframework.org/schema/beans"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
<bean id="MoveDisk" class="com.lym.springtest.MoveDisk"></bean>
<bean id="Computer" class="com.lym.springtest.Computer">
<property name="usb" ref="MoveDisk">
</property>
</bean>
</beans>