尝试使用spring-data-jpa时候遇到一个问题,启动时报错:(下边是一行日志,太长了,我人工的给换行了)

1
2
3
4
5
6
7
Offending resource: class path resource [applicationContext.xml];
nested exception is org.springframework.beans.factory.BeanDefinitionStoreException: 
Unexpected exception parsing XML document from class path resource [context/applicationContext-database.xml]; 
nested exception is org.springframework.beans.FatalBeanException: 
Invalid NamespaceHandler class [org.springframework.data.jpa.repository.config.JpaRepositoryNameSpaceHandler] 
for namespace [http://www.springframework.org/schema/data/jpa]: problem with handler class file or dependent class; 
nested exception is java.lang.NoClassDefFoundError: org/springframework/aop/framework/AbstractAdvisingBeanPostProcessor

数次尝试修复未果,求助谷歌大神,找到了不少难兄难弟: Google Query URL

其中这条中提到,有可能是spring-aop版本不对, http://stackoverflow.com/questions/16351553/invalid-namespacehandler-class-org-spring-framework-data-jpa-repository-config

在IDEA中查看Maven的依赖,发现Maven自动为spring-data-jpa下载了3.1.4.RELEASE版的spring-aop,而我的项目中,制定的依赖spring-webmvc,spring-orm是3.2.4版,根据依赖自动下载的spring-beans,spring-context,spring-core等均为3.2.4 在pom.xml中手动添加了添加了spring-aop的依赖后,系统正常启动

1
2
3
4
5
<dependency>
    <groupid>org.springframework</groupid>
    <artifactid>spring-aop</artifactid>
    <version>${spring.version}</version>
</dependency>