为了账号安全,请及时绑定邮箱和手机立即绑定

报错java.lang.IllegalStateException: Failed to load ApplicationContext为什么

[SpringTransaction] 2016-12-16 17:13:53   Loading XML bean definitions from class path resource [applicationContext.xml] 

[SpringTransaction] 2016-12-16 17:13:54   Refreshing org.springframework.context.support.GenericApplicationContext@52af6cff: startup date [Fri Dec 16 17:13:54 GMT+08:00 2016]; root of context hierarchy 

[SpringTransaction] 2016-12-16 17:13:54   Caught exception while allowing TestExecutionListener [org.springframework.test.context.support.DependencyInjectionTestExecutionListener@70beb599] to prepare test instance [spring.demo1.SpringDemo1@4e41089d] 

java.lang.IllegalStateException: Failed to load ApplicationContext

at org.springframework.test.context.TestContext.getApplicationContext(TestContext.java:157)

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

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

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

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

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

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

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

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

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

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:71)

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

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

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

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

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

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

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

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

Caused by: java.lang.IllegalArgumentException

at org.springframework.asm.ClassReader.<init>(Unknown Source)

at org.springframework.asm.ClassReader.<init>(Unknown Source)

at org.springframework.asm.ClassReader.<init>(Unknown Source)

at org.springframework.core.type.classreading.SimpleMetadataReader.<init>(SimpleMetadataReader.java:52)

at org.springframework.core.type.classreading.SimpleMetadataReaderFactory.getMetadataReader(SimpleMetadataReaderFactory.java:80)

at org.springframework.core.type.classreading.CachingMetadataReaderFactory.getMetadataReader(CachingMetadataReaderFactory.java:101)

at org.springframework.core.type.classreading.SimpleMetadataReaderFactory.getMetadataReader(SimpleMetadataReaderFactory.java:76)

at org.springframework.context.annotation.ConfigurationClassUtils.checkConfigurationClassCandidate(ConfigurationClassUtils.java:70)

at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:253)

at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:223)

at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:630)

at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:461)

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

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

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

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

at org.springframework.test.context.TestContext.loadApplicationContext(TestContext.java:124)

at org.springframework.test.context.TestContext.getApplicationContext(TestContext.java:148)

... 24 more


正在回答

5 回答

对了,还需要一个commons-logging包,包在隔壁的spring入门篇中可以找到。

0 回复 有任何疑惑可以回复我~

把spring开头的jar包换成版本4.05点。一共有9个。然后,配置文件不做修改,可以运行。。

3 回复 有任何疑惑可以回复我~
#1

qq_蓝海_12

啊啊啊啊,亲测可用啊,非常感谢!
2019-08-17 回复 有任何疑惑可以回复我~

为什么只能1.7才运行成功?


0 回复 有任何疑惑可以回复我~

果然改成1.7就好了。。。。

0 回复 有任何疑惑可以回复我~

我的也是啊,刚敲的代码,怎么解决啊

0 回复 有任何疑惑可以回复我~

举报

0/150
提交
取消

报错java.lang.IllegalStateException: Failed to load ApplicationContext为什么

我要回答 关注问题
意见反馈 帮助中心 APP下载
官方微信