我目前正在尝试启动并运行一个spring程序。我正在使用this示例来教我如何做。我已经完成了示例中所说的所有操作,除了在第12步中尝试运行它时,我得到一个错误。
Exception in thread "main" org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from class path resource [SpringHelloWorld.xml]; nested exception is java.io.FileNotFoundException: class path resource [SpringHelloWorld.xml] cannot be opened because it does not exist
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:341)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:302)
at org.springframework.beans.factory.xml.XmlBeanFactory.<init>(XmlBeanFactory.java:78)
at org.springframework.beans.factory.xml.XmlBeanFactory.<init>(XmlBeanFactory.java:66)
at net.roseindia.Spring3HelloWorldTest.main(Spring3HelloWorldTest.java:12)原因: org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:328)处的org.springframework.core.io.ClassPathResource.getInputStream(ClassPathResource.java:158)上不存在java.io.FileNotFoundException:类路径资源SpringHelloWorld.xml,因此无法打开它... 4更多信息
我是spring的新手,所以我真的不知道发生了什么。我知道在我的类中,我尝试导入org.springframework.beans.factory.xml.XmlBeanFactory;,,但我认为这是抛出错误或导致它无法工作的原因。
如果有人知道哪里出了问题,或者有一个更好的易于遵循的Spring示例,我们将不胜感激。
摩根
发布于 2012-05-15 01:09:40
将该XML文件放入CLASSPATH中。Bean工厂找不到您的配置文件。
您可以使用java.exe的-cp选项来执行此操作:
java -cp .;<individual-jars>;<directory-where-xml-config-lives> Spring3HelloWorldTesthttps://stackoverflow.com/questions/10587939
复制相似问题