java.lang.IllegalStateException: Failed to load ApplicationContext
Posted zhengjinjun
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了java.lang.IllegalStateException: Failed to load ApplicationContext相关的知识,希望对你有一定的参考价值。
java Spring AOP编写MAVEN项目,编译时出现错误提示如下:
java.lang.IllegalStateException: Failed to load ApplicationContext
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘customerService‘ defined in class path resource [applicationContext.xml]: BeanPostProcessor before instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘org.springframework.aop.support.DefaultBeanFactoryPointcutAdvisor#0‘: Cannot resolve reference to bean ‘mycut‘ while setting bean property ‘pointcut‘; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘mycut‘: Failed to introspect bean class [org.springframework.aop.aspectj.AspectJExpressionPointcut] for lookup method metadata: could not find class that it depends on; nested exception is java.lang.NoClassDefFoundError: org/aspectj/weaver/reflect/ReflectionWorld$ReflectionWorldException
刚开始以为是
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations="classpath:applicationContext.xml")
路径配置问题,
后来发现D:Program Filesapache-maven-3.2.3confsettings.xml文件中<mirrors>配置有问题:
<!-- 使用私服仓库,加上以下语句 -->
<!-- 若要使用网络(官网中央仓库),就注释掉,默认没有该语句,不用添加就行了 -->
<mirror>
<id>my</id>
<mirrorOf>*</mirrorOf>
<name>Human Readable Name for this Mirror.</name>
<url>私服仓库地址</url>
</mirror>
即使更改过来后还是报同样的错误,原因:
jar包一旦出现下载错误,则会在repository文件夹中生成.lastUpdated文件.
必须在D:Program Filesapache-maven-3.2.3 epository中查找并删掉对应的.lastUpdated文件,才会重新从中央仓库中下载,否则是下载不了的.
批删除.lastUpdated文件小技巧: 创建cleanLastUpdated.bat文件双击运行即可.
文件内容如下:
set REPOSITORY_PATH=D:Program Filesapache-maven-3.2.3
epository
rem 正在搜索...
for /f "delims=" %%i in (‘dir /b /s "%REPOSITORY_PATH%*lastUpdated"‘) do (
del /s /q %%i
)
rem 搜索完毕
pause
<!-- 初学者,第一次发表博客,若有不当之处还请见谅! -->
以上是关于java.lang.IllegalStateException: Failed to load ApplicationContext的主要内容,如果未能解决你的问题,请参考以下文章