spring - 收到错误消息,找不到元素 'jpa:repositories' 的声明

标签 spring jpa-2.0

我收到以下错误

Line 84 in XML document from class path resource [car-job-app-context.xml] is 
invalid; nested exception is org.xml.sax.SAXParseException; lineNumber: 84; 
columnNumber: 154; cvc-complex-type.2.4.c: The matching wildcard is strict, but
no declaration can be found for element 'jpa:repositories'.

这是我的文件

<?xml version="1.0" encoding="UTF-8"?>

<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:jpa="http://www.springframework.org/schema/data/jpa"
    xmlns:tx="http://www.springframework.org/schema/tx"
    xmlns:repository="http://www.springframework.org/schema/data/repository"
    xsi:schemaLocation="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/jdbc
                        http://www.springframework.org/schema/jdbc/spring-jdbc-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/tx
                        http://www.springframework.org/schema/tx/spring-tx-3.2.xsd
                        http://www.springframework.org/schema/data/jpa
                        http://www.springframework.org/schema/data/jpa/spring-jpa-2.0.xsd" >

.....

<context:annotation-config/>

<context:component-scan base-package="pk.training.basitMahmood.service.impl" />

<jpa:repositories base-package="pk.training.basitMahmood.repository" entity-manager-factory-ref="emf" transaction-manager-ref="transactionManager" />

这是我的 maven 依赖项的快照

Maven Dependency JARS

我还看到了相同的链接,上面写着将 tx declaration 移到 context 之后,但它不起作用。 same post as my question .我试过前后组合,但错误仍然存​​在。

为什么我会收到这个错误?我无法在数据库中保存数据....?

谢谢

最佳答案

命名空间的顺序无关紧要。确保 spring-data-jpa 工件在您的类路径中,并仔细检查架构版本。没有 spring-jpa-2.0 这样的东西。它应该介于 1.0 和 1.3 之间。使用 Spring,您通常也可以省略版本并默认获取最新的模式。

关于spring - 收到错误消息,找不到元素 'jpa:repositories' 的声明,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16747445/

相关文章:

hibernate - JPA @Version行为

java - 为什么尽管禁用共享缓存仍需要 JPA 实体刷新?

java - Spring MVC 教程项目不基于 IntelliJ 构建

java - 如何在 Grails 3 应用程序中为公共(public)文件启用合理的默认缓存?

Spring - 使用属性扩展(processResources)并在application.yml文件中使用属性引用时发生冲突

hibernate - JPA 2.0 subselect/subquery in order by 子句和条件api

jpa-2.0 - 无法使@ManyToOne关系为空

spring - 组合 hibernate @Transactional & ehcache @Cacheable 总是创建数据库事务

java - 更改 "roll back"的最佳方法是什么?

java - JPA 嵌套事务和锁定