ClassPathXmlApplicationContext 加载不到dubbo.xml

发布于 2021-11-24 12:45:43 字数 13283 浏览 806 评论 9


maven项目在test包里执行main方法:

代码如下

ApplicationContext context = new ClassPathXmlApplicationContext("dubbo.xml");
异常如下:

/usr/local/software/jdk/jdk1.7.0_79/bin/java -agentlib:jdwp=transport=dt_socket,address=127.0.0.1:47613,suspend=y,server=n -Dfile.encoding=UTF-8 -classpath /usr/local/software/jdk/jdk1.7.0_79/jre/lib/javaws.jar:/usr/local/software/jdk/jdk1.7.0_79/jre/lib/plugin.jar:/usr/local/software/jdk/jdk1.7.0_79/jre/lib/charsets.jar:/usr/local/software/jdk/jdk1.7.0_79/jre/lib/rt.jar:/usr/local/software/jdk/jdk1.7.0_79/jre/lib/deploy.jar:/usr/local/software/jdk/jdk1.7.0_79/jre/lib/jfxrt.jar:/usr/local/software/jdk/jdk1.7.0_79/jre/lib/management-agent.jar:/usr/local/software/jdk/jdk1.7.0_79/jre/lib/resources.jar:/usr/local/software/jdk/jdk1.7.0_79/jre/lib/jce.jar:/usr/local/software/jdk/jdk1.7.0_79/jre/lib/jfr.jar:/usr/local/software/jdk/jdk1.7.0_79/jre/lib/jsse.jar:/usr/local/software/jdk/jdk1.7.0_79/jre/lib/ext/sunec.jar:/usr/local/software/jdk/jdk1.7.0_79/jre/lib/ext/zipfs.jar:/usr/local/software/jdk/jdk1.7.0_79/jre/lib/ext/localedata.jar:/usr/local/software/jdk/jdk1.7.0_79/jre/lib/ext/sunjce_provider.jar:/usr/local/software/jdk/jdk1.7.0_79/jre/lib/ext/dnsns.jar:/usr/local/software/jdk/jdk1.7.0_79/jre/lib/ext/sunpkcs11.jar:/home/xinhuanet/workspace/sso-website/target/test-classes:/home/xinhuanet/workspace/sso-website/target/classes:/home/xinhuanet/.m2/repository/antlr/antlr/2.7.7/antlr-2.7.7.jar:/home/xinhuanet/.m2/repository/javax/activation/activation/1.1.1/activation-1.1.1.jar:/home/xinhuanet/.m2/repository/aspectj/aspectjrt/1.0.5/aspectjrt-1.0.5.jar:/home/xinhuanet/.m2/repository/org/aopalliance/com.springsource.org.aopalliance/1.0.0/com.springsource.org.aopalliance-1.0.0.jar:/home/xinhuanet/.m2/repository/org/aspectj/aspectjweaver/1.8.1/aspectjweaver-1.8.1.jar:/home/xinhuanet/.m2/repository/cglib/cglib-nodep/2.1_3/cglib-nodep-2.1_3.jar:/home/xinhuanet/.m2/repository/org/wltea/expression/ik-expression/2.1.2/ik-expression-2.1.2-jdk15.jar:/home/xinhuanet/.m2/repository/com/belerweb/weibo4j-oauth2/2.1.1-beta2-1/weibo4j-oauth2-2.1.1-beta2-1.jar:/home/xinhuanet/.m2/repository/org/json/json/20080701/json-20080701.jar:/home/xinhuanet/.m2/repository/commons-beanutils/commons-beanutils/1.8.3/commons-beanutils-1.8.3.jar:/home/xinhuanet/.m2/repository/commons-logging/commons-logging/1.1.1/commons-logging-1.1.1.jar:/home/xinhuanet/.m2/repository/commons-codec/commons-codec/1.3/commons-codec-1.3.jar:/home/xinhuanet/.m2/repository/commons-collections/commons-collections/3.1/commons-collections-3.1.jar:/home/xinhuanet/.m2/repository/commons-configuration/commons-configuration/1.8/commons-configuration-1.8.jar:/home/xinhuanet/.m2/repository/commons-lang/commons-lang/2.6/commons-lang-2.6.jar:/home/xinhuanet/.m2/repository/commons-fileupload/commons-fileupload/1.0/commons-fileupload-1.0.jar:/home/xinhuanet/.m2/repository/commons-httpclient/commons-httpclient/3.1/commons-httpclient-3.1.jar:/home/xinhuanet/.m2/repository/commons-io/commons-io/2.1/commons-io-2.1.jar:/home/xinhuanet/.m2/repository/org/apache/commons/com.springsource.org.apache.commons.lang/2.4.0/com.springsource.org.apache.commons.lang-2.4.0.jar:/home/xinhuanet/.m2/repository/org/apache/commons/commons-pool2/2.3/commons-pool2-2.3.jar:/home/xinhuanet/.m2/repository/dom4j/dom4j/1.6.1/dom4j-1.6.1.jar:/home/xinhuanet/.m2/repository/com/alibaba/dubbo/2.4.9/dubbo-2.4.9.jar:/home/xinhuanet/.m2/repository/org/springframework/spring/2.5.6.SEC03/spring-2.5.6.SEC03.jar:/home/xinhuanet/.m2/repository/org/javassist/javassist/3.15.0-GA/javassist-3.15.0-GA.jar:/home/xinhuanet/.m2/repository/com/alibaba/fastjson/1.1.23/fastjson-1.1.23.jar:/home/xinhuanet/.m2/repository/org/apache/httpcomponents/httpclient/4.2.1/httpclient-4.2.1.jar:/home/xinhuanet/.m2/repository/org/apache/httpcomponents/httpclient-cache/4.2.1/httpclient-cache-4.2.1.jar:/home/xinhuanet/.m2/repository/org/apache/httpcomponents/httpcore/4.2.1/httpcore-4.2.1.jar:/home/xinhuanet/.m2/repository/jcaptcha/jcaptcha-all/1.0-RC6/jcaptcha-all-1.0-RC6-RC6.jar:/home/xinhuanet/.m2/repository/net/sf/json-lib/json-lib/2.4/json-lib-2.4-jdk15.jar:/home/xinhuanet/.m2/repository/javax/servlet/jsp/jstl/javax.servlet.jsp.jstl-api/1.2.1/javax.servlet.jsp.jstl-api-1.2.1.jar:/home/xinhuanet/.m2/repository/org/apache/taglibs/com.springsource.org.apache.taglibs.standard/1.1.2/com.springsource.org.apache.taglibs.standard-1.1.2.jar:/home/xinhuanet/.m2/repository/javax/transaction/jta/1.1/jta-1.1.jar:/home/xinhuanet/.m2/repository/javax/mail/mail/1.5.0-b01/mail-1.5.0-b01.jar:/home/xinhuanet/.m2/repository/org/apache/thrift/libthrift/0.8.0/libthrift-0.8.0.jar:/home/xinhuanet/.m2/repository/org/slf4j/slf4j-api/1.5.8/slf4j-api-1.5.8.jar:/home/xinhuanet/.m2/repository/log4j/log4j/1.2.12/log4j-1.2.12.jar:/home/xinhuanet/.m2/repository/org/jboss/netty/netty/3.2.5.Final/netty-3.2.5.Final.jar:/home/xinhuanet/.m2/repository/xml-apis/xml-apis/1.4.01/xml-apis-1.4.01.jar:/home/xinhuanet/.m2/repository/org/slf4j/slf4j-log4j12/1.6.6/slf4j-log4j12-1.6.6.jar:/home/xinhuanet/.m2/repository/com/101tec/zkclient/0.2/zkclient-0.2.jar:/home/xinhuanet/.m2/repository/org/apache/zookeeper/zookeeper/3.3.6/zookeeper-3.3.6.jar:/home/xinhuanet/.m2/repository/jline/jline/0.9.94/jline-0.9.94.jar:/home/xinhuanet/.m2/repository/junit/junit/3.8.1/junit-3.8.1.jar:/home/xinhuanet/.m2/repository/net/sf/ezmorph/ezmorph/1.0.4/ezmorph-1.0.4.jar:/home/xinhuanet/.m2/repository/jaxen/jaxen/1.1.6/jaxen-1.1.6.jar:/home/xinhuanet/.m2/repository/commons-dbcp/commons-dbcp/1.4/commons-dbcp-1.4.jar:/home/xinhuanet/.m2/repository/commons-pool/commons-pool/1.5.4/commons-pool-1.5.4.jar:/home/xinhuanet/.m2/repository/org/jdom/jdom/2.0.2/jdom-2.0.2.jar:/home/xinhuanet/.m2/repository/org/jsoup/jsoup/1.7.3/jsoup-1.7.3.jar:/home/xinhuanet/.m2/repository/org/apache/httpcomponents/httpmime/4.1.3/httpmime-4.1.3.jar:/home/xinhuanet/.m2/repository/hsqldb/hsqldb/1.8.0.7/hsqldb-1.8.0.7.jar:/home/xinhuanet/.m2/repository/ehcache/ehcache/1.1/ehcache-1.1.jar:/home/xinhuanet/.m2/repository/xerces/xercesImpl/2.11.0/xercesImpl-2.11.0.jar:/home/xinhuanet/.m2/repository/xalan/xalan/2.7.1/xalan-2.7.1.jar:/home/xinhuanet/.m2/repository/xalan/serializer/2.7.1/serializer-2.7.1.jar:/home/xinhuanet/.m2/repository/quartz/quartz-weblogic/1.5.1/quartz-weblogic-1.5.1.jar:/home/xinhuanet/.m2/repository/org/springframework/org.springframework.aspects/3.1.1.RELEASE/org.springframework.aspects-3.1.1.RELEASE.jar:/home/xinhuanet/.m2/repository/org/springframework/org.springframework.asm/3.1.1.RELEASE/org.springframework.asm-3.1.1.RELEASE.jar:/home/xinhuanet/.m2/repository/org/springframework/org.springframework.aop/3.1.1.RELEASE/org.springframework.aop-3.1.1.RELEASE.jar:/home/xinhuanet/.m2/repository/org/springframework/org.springframework.beans/3.1.1.RELEASE/org.springframework.beans-3.1.1.RELEASE.jar:/home/xinhuanet/.m2/repository/org/springframework/org.springframework.core/3.1.1.RELEASE/org.springframework.core-3.1.1.RELEASE.jar:/home/xinhuanet/.m2/repository/org/springframework/org.springframework.context/3.1.1.RELEASE/org.springframework.context-3.1.1.RELEASE.jar:/home/xinhuanet/.m2/repository/org/springframework/org.springframework.context.support/3.1.1.RELEASE/org.springframework.context.support-3.1.1.RELEASE.jar:/home/xinhuanet/.m2/repository/org/springframework/org.springframework.expression/3.1.1.RELEASE/org.springframework.expression-3.1.1.RELEASE.jar:/home/xinhuanet/.m2/repository/org/springframework/org.springframework.jdbc/3.1.1.RELEASE/org.springframework.jdbc-3.1.1.RELEASE.jar:/home/xinhuanet/.m2/repository/org/springframework/org.springframework.jms/3.1.1.RELEASE/org.springframework.jms-3.1.1.RELEASE.jar:/home/xinhuanet/.m2/repository/org/springframework/org.springframework.orm/3.1.1.RELEASE/org.springframework.orm-3.1.1.RELEASE.jar:/home/xinhuanet/.m2/repository/org/springframework/org.springframework.oxm/3.1.1.RELEASE/org.springframework.oxm-3.1.1.RELEASE.jar:/home/xinhuanet/.m2/repository/org/springframework/org.springframework.transaction/3.1.1.RELEASE/org.springframework.transaction-3.1.1.RELEASE.jar:/home/xinhuanet/.m2/repository/org/springframework/org.springframework.web/3.1.4.RELEASE/org.springframework.web-3.1.4.RELEASE.jar:/home/xinhuanet/.m2/repository/org/springframework/org.springframework.web.servlet/3.1.4.RELEASE/org.springframework.web.servlet-3.1.4.RELEASE.jar:/home/xinhuanet/.m2/repository/com/xinhuanet/XHMsg/0.1/XHMsg-0.1.jar:/home/xinhuanet/.m2/repository/cn/news/filter/0.10.0-SNAPSHOT/filter-0.10.0-20150428.061017-2.jar:/home/xinhuanet/workspace/xhsso/sessionutils/target/classes:/home/xinhuanet/.m2/repository/javax/servlet/servlet-api/2.4/servlet-api-2.4.jar:/home/xinhuanet/.m2/repository/com/googlecode/xmemcached/xmemcached/1.3.8/xmemcached-1.3.8.jar:/home/xinhuanet/.m2/repository/redis/clients/jedis/2.6.2/jedis-2.6.2.jar:/home/xinhuanet/.m2/repository/com/esotericsoftware/kryo/kryo/2.23.0/kryo-2.23.0.jar:/home/xinhuanet/.m2/repository/com/esotericsoftware/minlog/minlog/1.2/minlog-1.2.jar:/home/xinhuanet/.m2/repository/org/objenesis/objenesis/2.1/objenesis-2.1.jar:/home/xinhuanet/.m2/repository/com/xinhuanet/xh-user-center/0.9.0/xh-user-center-0.9.0.jar:/home/xinhuanet/.m2/repository/com/xinhuanet/xh-relationship-center/0.13/xh-relationship-center-0.13.jar:/home/xinhuanet/.m2/repository/com/xinhuanet/shareApp/0.0.9/shareApp-0.0.9.jar:/home/xinhuanet/.m2/repository/com/xinhuanet/authSystem/0.1.3/authSystem-0.1.3.jar:/home/xinhuanet/.m2/repository/org/apache/poi/poi/3.9/poi-3.9.jar:/home/xinhuanet/.m2/repository/org/mongodb/mongo-java-driver/3.0.0-beta3/mongo-java-driver-3.0.0-beta3.jar:/home/xinhuanet/.m2/repository/io/netty/netty-buffer/4.0.24.Final/netty-buffer-4.0.24.Final.jar:/home/xinhuanet/.m2/repository/io/netty/netty-common/4.0.24.Final/netty-common-4.0.24.Final.jar:/home/xinhuanet/.m2/repository/io/netty/netty-handler/4.0.24.Final/netty-handler-4.0.24.Final.jar:/home/xinhuanet/.m2/repository/io/netty/netty-transport/4.0.24.Final/netty-transport-4.0.24.Final.jar:/home/xinhuanet/.m2/repository/io/netty/netty-codec/4.0.24.Final/netty-codec-4.0.24.Final.jar:/home/xinhuanet/workspace/xhsso/dubboIface/target/classes:/home/xinhuanet/workspace/xhsso/util/target/classes:/home/xinhuanet/.m2/repository/com/belerweb/pinyin4j/2.5.0/pinyin4j-2.5.0.jar:/home/xinhuanet/workspace/xhsso/client/target/classes:/usr/local/idea/lib/idea_rt.jar sso.TestSSOWEBDubbo
Connected to the target VM, address: '127.0.0.1:47613', transport: 'socket'
log4j:WARN No appenders could be found for logger (org.springframework.context.support.ClassPathXmlApplicationContext).
log4j:WARN Please initialize the log4j system properly.
Exception in thread "main" org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from class path resource [dubbo.xml]; nested exception is java.io.FileNotFoundException: class path resource [dubbo.xml] cannot be opened because it does not exist
	at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:349)
	at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:310)
	at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:143)
	at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:178)
	at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:149)
	at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:212)
	at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:113)
	at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:80)
	at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:123)
	at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:422)
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:352)
	at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
	at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83)
	at sso.TestSSOWEBDubbo.main(TestSSOWEBDubbo.java:18)
Caused by: java.io.FileNotFoundException: class path resource [dubbo.xml] cannot be opened because it does not exist
	at org.springframework.core.io.ClassPathResource.getInputStream(ClassPathResource.java:143)
	at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:336)
	... 13 more
Disconnected from the target VM, address: '127.0.0.1:47613', transport: 'socket'

Process finished with exit code 1


请指点啊


如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(9

残花月 2021-12-01 07:23:33

右击你的resource目录,然后mark it as resourse

德意的啸 2021-12-01 06:56:08

原因是:intellij idea 编译发布时没有拷贝resource里的资源文件, 但不知道应该怎么解决?!

风苍溪 2021-12-01 06:28:47

class path resource [dubbo.xml] cannot be opened because it does not exist

是不是文件路径的问题,报错说的是dubbo.xml 不存在

月牙弯弯 2021-12-01 04:46:43

原因是:intellij idea 编译发布时没有拷贝resource里的资源文件, 但不知道应该怎么解决?

甜扑 2021-11-30 13:33:14

回复
project settings(选择项目F4) -》modules -》paths(在右边) -》 compiler output 选中 inherit 这一行保存 重新编译 试试

深巷少女 2021-11-30 09:19:26

原因是:intellij idea 编译发布时没有拷贝resource里的资源文件, 但不知道应该怎么解决?!

筱果果 2021-11-30 08:50:33

dubbo.位置放的不正确,要放在src目录里

嘦怹 2021-11-29 19:00:01

原因是:intellij idea 编译发布时没有拷贝resource里的资源文件, 但不知道应该怎么解决?

梅窗月明清似水 2021-11-27 00:59:36

如果
dubbo.xml在src下 这么写:  classpath*:
dubbo.xml ,如果在别的路径下就把路劲加上,如在src/spring下 则写成  classpath*:spring/dubbo.xml

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文