获取错误无效的NamespaceHandler类org.springframework.data.jpa.repository.config.JpaRepositoryNameSpaceHandler

时间:2013-05-03 07:57:26

标签: spring

在跑春天的时候我遇到了错误

Unexpected exception parsing XML document from class path resource 
[spring/tx-annotation-app-context.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/data/repository/config/RepositoryConfigurationExtension

这是我的档案

<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xmlns:context="http://www.springframework.org/schema/context"
xmlns:jdbc="http://www.springframework.org/schema/jdbc" 
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:jpa="http://www.springframework.org/schema/data/jpa"
xsi:schemaLocation="http://www.springframework.org/schema/jdbc 
                    http://www.springframework.org/schema/jdbc/spring-jdbc-3.1.xsd
                    http://www.springframework.org/schema/beans 
                    http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
                    http://www.springframework.org/schema/tx 
                    http://www.springframework.org/schema/tx/spring-tx-3.1.xsd
                    http://www.springframework.org/schema/data/jpa 
                    http://www.springframework.org/schema/data/jpa/spring-jpa-1.2.xsd
                    http://www.springframework.org/schema/context 
                    http://www.springframework.org/schema/context/spring-context-3.1.xsd">

<description>Example configuration to get you started.</description>
    ....
</beans>

以下是我所包含的罐子的屏幕截图

spring jars

我对命名空间做错了什么?

由于

1 个答案:

答案 0 :(得分:1)

我认为问题在于您使用spring-data-commons-core版本1.1和spring-data-jpa版本1.2。对齐这些库的版本。

从我看到的一个项目中查看pom.xml文件。

<dependency>
    <groupId>org.springframework.data</groupId>
    <artifactId>spring-data-jpa</artifactId>
    <version>1.2.0.RELEASE</version>
</dependency>

它使用spring-data-commons-core-1.4.0.RELEASE.jar

如果您将spring-data-jpa的包装切换为pom,则应下载必要的依赖项,然后将其切换回jar