2012-05-14 41 views
0

我目前正试图启动并运行一个弹簧程序。我正在使用this示例教我如何做到这一点。除了当我尝试在步骤12中运行它时,我已经完成了所有示例的说明,但出现错误。Spring 3 HelloWorld程序

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) 

所致:java.io.FileNotFoundException:类路径资源[SpringHelloWorld.xml]不能被打开,因为它不在org.springframework.core.io.ClassPathResource.getInputStream(ClassPathResource.java存在 : 158) 在org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:328) ... 4个

我真的很新的春天,所以我真的不知道发生了什么。我知道在我的班级中,我尝试导入org.springframework.beans.factory.xml.XmlBeanFactory;但我认为这是抛出错误或导致它不工作的原因。

如果有人知道出了什么问题,或者更好的Spring例子,很容易遵循它将不胜感激。

Morgan Morgan

回答

0

将该XML文件放入您的CLASSPATH中。 Bean Factory无法找到您的配置文件。

你这样做,使用-cp选项JAVA.EXE:

java -cp .;<individual-jars>;<directory-where-xml-config-lives> Spring3HelloWorldTest 
相关问题