+-
java – 元素“jpa:repositories”的前缀“jpa”未绑定
当我尝试做mvn clean install时,我收到此错误:

[INFO] Caused by: org.xml.sax.SAXParseException; lineNumber: 38; columnNumber: 64; The prefix "jpa" for element "jpa:repositories" is not bound.

我有的spring上下文xml是:

<?xml version="1.0" encoding="UTF-8"?>  
    <beans xmlns="http://www.springframework.org/schema/beans"  
     xmlns:mvc="http://www.springframework.org/schema/mvc"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
     xmlns:task="http://www.springframework.org/schema/task"  
     xmlns:context="http://www.springframework.org/schema/context"  
     xmlns:tx="http://www.springframework.org/schema/tx"  
     xmlns:oxm="http://www.springframework.org/schema/oxm"
     xmlns:security="http://www.springframework.org/schema/security"
     xsi:schemaLocation="http://www.springframework.org/schema/mvc 
            http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd
            http://www.springframework.org/schema/task   
            http://www.springframework.org/schema/task/spring-task-3.2.xsd
            http://www.springframework.org/schema/beans   
            http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
            http://www.springframework.org/schema/context
            http://www.springframework.org/schema/context/spring-context-3.2.xsd
            http://www.springframework.org/schema/tx  
            http://www.springframework.org/schema/tx/spring-tx-3.2.xsd
            http://www.springframework.org/schema/data/repository
            http://www.springframework.org/schema/data/repository/spring-repository.xsd
            http://www.springframework.org/schema/util
            http://www.springframework.org/schema/util/spring-util.xsd
            http://www.springframework.org/schema/data/jpa
            http://www.springframework.org/schema/data/jpa/spring-jpa.xsd
            http://www.springframework.org/schema/oxm 
            http://www.springframework.org/schema/oxm/spring-oxm-3.2.xsd
            http://www.springframework.org/schema/security 
            http://www.springframework.org/schema/security/spring-security-3.2.xsd
            http://www.springframework.org/schema/data/jpa
           http://www.springframework.org/schema/data/jpa/spring-jpa.xsd">

上下文XML中可能缺少什么?

也有pom.xml

<!-- Spring Data -->
<dependency>
    <groupId>org.springframework.data</groupId>
    <artifactId>spring-data-jpa</artifactId>
    <version>1.6.0.RELEASE</version>
    <scope>compile</scope>
</dependency>
最佳答案
将jpa名称空间声明添加到应用程序上下文文件中的beans标记定义

<?xml version="1.0" encoding="UTF-8"?>  
    <beans xmlns="http://www.springframework.org/schema/beans"  
     xmlns:mvc="http://www.springframework.org/schema/mvc"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
     xmlns:task="http://www.springframework.org/schema/task"  
     xmlns:context="http://www.springframework.org/schema/context"  
     xmlns:tx="http://www.springframework.org/schema/tx"  
     xmlns:oxm="http://www.springframework.org/schema/oxm"
     xmlns:security="http://www.springframework.org/schema/security"
     xmlns:jpa="http://www.springframework.org/schema/data/jpa"  <---

阅读:JPA Repositories

点击查看更多相关文章

转载注明原文:java – 元素“jpa:repositories”的前缀“jpa”未绑定 - 乐贴网