日期:2014-05-20  浏览次数:20824 次

spring中xml如何配置
通过BeanFactory factory=new XmlBeanFactory((Resource) new FileInputStream("helloword.xml"));读取helloword.xml时出现java.io.FileNotFoundException: helloword.xml (系统找不到指定的文件。)错误,应该怎么设置xml的关联,我是直接在类的包里面建立一个xml文件,输入内容的.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"
"http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
<bean id="greetingService"
class="com.GreetingServiceImpl">
<property name="greeting">
<value>fq</value>
</property>
</bean>
</beans>

------解决方案--------------------
new FileInputStream("helloword.xml")); 这个xml换绝对路径看看。
------解决方案--------------------
new FileSystemXmlApplicationContext("yourxml");
------解决方案--------------------
文件找不到 文件放对位置没 是不是在当前文件所在包同级目录