报错情况和教程不一样

报错情况和教程不一样

六月 24, 2020 11:00:06 下午 org.springframework.test.context.support.DefaultTestContextBootstrapper getDefaultTestExecutionListenerClassNames

信息: Loaded default TestExecutionListener class names from location [META-INF/spring.factories]: [org.springframework.test.context.web.ServletTestExecutionListener, org.springframework.test.context.support.DirtiesContextBeforeModesTestExecutionListener, org.springframework.test.context.support.DependencyInjectionTestExecutionListener, org.springframework.test.context.support.DirtiesContextTestExecutionListener, org.springframework.test.context.transaction.TransactionalTestExecutionListener, org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener]

六月 24, 2020 11:00:06 下午 org.springframework.test.context.support.DefaultTestContextBootstrapper getTestExecutionListeners

信息: Using TestExecutionListeners: [org.springframework.test.context.web.ServletTestExecutionListener@4157f54e, org.springframework.test.context.support.DirtiesContextBeforeModesTestExecutionListener@90f6bfd, org.springframework.test.context.support.DependencyInjectionTestExecutionListener@47f6473, org.springframework.test.context.support.DirtiesContextTestExecutionListener@15975490, org.springframework.test.context.transaction.TransactionalTestExecutionListener@6b143ee9, org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener@1936f0f5]

六月 24, 2020 11:00:06 下午 org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions

信息: Loading XML bean definitions from class path resource [spring/spring-dao.xml]

六月 24, 2020 11:00:06 下午 org.springframework.test.context.TestContextManager prepareTestInstance

严重: Caught exception while allowing TestExecutionListener [org.springframework.test.context.support.DependencyInjectionTestExecutionListener@47f6473] to prepare test instance [com.imooc.o2o.dao.AreaDaoTest@4b4523f8]

java.lang.IllegalStateException: Failed to load ApplicationContext

at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:124)

at org.springframework.test.context.support.DefaultTestContext.getApplicationContext(DefaultTestContext.java:83)

at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.injectDependencies(DependencyInjectionTestExecutionListener.java:117)

at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.prepareTestInstance(DependencyInjectionTestExecutionListener.java:83)

at org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:230)

at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.createTest(SpringJUnit4ClassRunner.java:228)

at org.springframework.test.context.junit4.SpringJUnit4ClassRunner$1.runReflectiveCall(SpringJUnit4ClassRunner.java:287)

at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)

at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.methodBlock(SpringJUnit4ClassRunner.java:289)

at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:247)

at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:94)

at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)

at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)

at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)

at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)

at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)

at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)

at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)

at org.junit.runners.ParentRunner.run(ParentRunner.java:363)

at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:191)

at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:89)

at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:41)

at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:541)

at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:763)

at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:463)

at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:209)

Caused by: org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from class path resource [spring/spring-dao.xml]; nested exception is java.io.FileNotFoundException: class path resource [spring/spring-dao.xml] cannot be opened because it does not exist

at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:344)

at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:304)

at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:181)

at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:217)

at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:188)

at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:252)

at org.springframework.test.context.support.AbstractGenericContextLoader.loadBeanDefinitions(AbstractGenericContextLoader.java:257)

at org.springframework.test.context.support.AbstractGenericContextLoader.loadContext(AbstractGenericContextLoader.java:124)

at org.springframework.test.context.support.AbstractGenericContextLoader.loadContext(AbstractGenericContextLoader.java:60)

at org.springframework.test.context.support.AbstractDelegatingSmartContextLoader.delegateLoading(AbstractDelegatingSmartContextLoader.java:108)

at org.springframework.test.context.support.AbstractDelegatingSmartContextLoader.loadContext(AbstractDelegatingSmartContextLoader.java:251)

at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContextInternal(DefaultCacheAwareContextLoaderDelegate.java:98)

at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:116)

... 25 more

Caused by: java.io.FileNotFoundException: class path resource [spring/spring-dao.xml] cannot be opened because it does not exist

at org.springframework.core.io.ClassPathResource.getInputStream(ClassPathResource.java:172)

at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:330)

... 37 more


正在回答 回答被采纳积分+1

登陆购买课程后可参与讨论,去登陆

6回答
好帮手慕阿慧 2020-06-25 16:07:25

同学你好,

1、同学检查一下Eclipse中Maven配置是否正确。

选择Windows->Preferences,如下:

http://img1.sycdn.imooc.com//climg/5ef45858098483b302500202.jpg

b. 选择自己的Maven,如下:

http://img1.sycdn.imooc.com//climg/5ef458f909a7acfe06720554.jpg

c.查看Maven仓库配置是否正确,如下:

http://img1.sycdn.imooc.com//climg/5ef458ff095ed94e06720554.jpg

2、

a. 关闭target下打开的文件。项目右击选择Clean,如下:

http://img1.sycdn.imooc.com//climg/5ef4599d0983d92306330470.jpg

b.项目右击选择Maven build... ,如下:

http://img1.sycdn.imooc.com//climg/5ef459db099afe8706160443.jpg

在弹出的页面中,选择Workspace..,选择o2o项目,如下:

http://img1.sycdn.imooc.com//climg/5ef45a1e09a2990b06730254.jpg

在“Goals”后的文本框内输入“-X package”,勾选上下方的“update snapshots”和“skip tests”,然后点击右下方的“run”,如下:

http://img1.sycdn.imooc.com//climg/5ef45aa309b8a1c708730624.jpg

target下会生成o2o文件夹。同学再找一下试试。

如果我的回答解决了你的疑惑,请采纳!祝学习愉快~

提问者 慕函数4736799 2020-06-25 14:11:13
好帮手慕阿慧 2020-06-25 10:27:49

同学你好,

报错信息:Caused by: java.io.FileNotFoundException: class path resource [spring/spring-dao.xml] cannot be opened because it does not exist

报错可能是因为没有在spring文件夹下找到spring-dao.xml文件。

同学可以查看一下target下是否有spring-dao.xml文件,如下:

http://img1.sycdn.imooc.com//climg/5ef40b9809560ebe04190863.jpg

如果没有,建议同学编译一下项目。

2、同学可以修改一下pom.xml再保存,Eclipse会自动下载依赖。

如果我的回答解决了你的疑惑,请采纳!祝学习愉快!

  • 提问者 慕函数4736799 #1
    老师,我的目录是这样的,可以帮我看看么,我在回复中展示。和老师的不一样呢,完全没有那些文件,老师并没有讲,这是eclipse自动导入到target里的么?还是要设置什么让她自动导入
    2020-06-25 14:09:11
  • 提问者 慕函数4736799 #2
    我重新下载了maven,可是本地仓库还是空的。我也想知道怎么一下子导入源码,直接跳过这个步骤。。我感觉我的目录和老师不太一样
    2020-06-25 14:17:16
  • 提问者 慕函数4736799 #3
    工程也总是报错,但是文件夹没有一个是报错的
    2020-06-25 14:17:53
提问者 慕函数4736799 2020-06-25 01:14:37

http://img1.sycdn.imooc.com//climg/5ef3891e09f9280713660736.jpg变成这样了。。。我不知道自己是动力那个配置变成这样的,按理说不应该的。然后我为了看是不是maven出问题就把maven库全删了(我怀疑我删了maven)。。。然后就出现了以下的错误。我想老师帮我看一下第一次错误在哪里,然后这个错误显示是我吧maven删了还是把本地仓库清空了。然后想问一下老师怎么一下子导入代码


提问者 慕函数4736799 2020-06-25 00:30:11

这些是我的配置出的问题么?可是配置并没有错误啊,我是用的教程资料。

提问者 慕函数4736799 2020-06-25 00:28:29

我看了一下那些类,我根本没有创建那些类啊,,,,,莫名其妙多出来的,而且我还不知道他们到底在哪里,根本找不到

问题已解决,确定采纳
还有疑问,暂不采纳

恭喜解决一个难题,获得1积分~

来为老师/同学的回答评分吧

0 星
请稍等 ...
意见反馈 帮助中心 APP下载
官方微信

在线咨询

领取优惠

免费试听

领取大纲

扫描二维码,添加
你的专属老师