首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Spring 3 HelloWorld计划

Spring 3 HelloWorld计划
EN

Stack Overflow用户
提问于 2012-05-15 01:07:17
回答 1查看 913关注 0票数 0

我目前正在尝试启动并运行一个spring程序。我正在使用this示例来教我如何做。我已经完成了示例中所说的所有操作,除了在第12步中尝试运行它时,我得到一个错误。

代码语言:javascript
复制
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示例,我们将不胜感激。

摩根

EN

回答 1

Stack Overflow用户

发布于 2012-05-15 01:09:40

将该XML文件放入CLASSPATH中。Bean工厂找不到您的配置文件。

您可以使用java.exe的-cp选项来执行此操作:

代码语言:javascript
复制
java -cp .;<individual-jars>;<directory-where-xml-config-lives> Spring3HelloWorldTest
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/10587939

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档