gpt4 book ai didi

Spring-Data-JPA 使用 XML 配置在 Spring STS 中导致 XSD 验证错误

转载 作者:行者123 更新时间:2023-12-01 10:01:58 25 4
gpt4 key购买 nike

Eclipse/STS 结合使用Spring 3.2.1 和Spring-data-jpa 报错。我有一些带有以下 header 的 XML 配置文件:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop" xmlns:p="http://www.springframework.org/schema/p"
xmlns:jpa="http://www.springframework.org/schema/data/jpa"
xsi:schemaLocation="
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop.xsd
http://www.springframework.org/schema/data/jpa
http://www.springframework.org/schema/data/jpa/spring-jpa.xsd">

我将 Spring 3.2.1 与 Spring-Data-JPA 1.3.0 一起使用,Eclipse/STS 报告如下:

Referenced file contains errors (http://www.springframework.org/schema/data/jpa)

这发生在每个包含 data-jpa 模式的 XML 配置文件中。当我从 XML 配置中删除 JPA 时,一切都很好。

是我的配置有误还是这里发生了什么?

谢谢!保罗

最佳答案

今天没有 http://www.springframework.org/schema/data/jpa/spring-jpa.xml文件所以你必须使用http://www.springframework.org/schema/data/jpa/spring-jpa-1.3.xsd , 但此文件使用 http://www.springframework.org/schema/data/repository/spring-repository.xsd也不存在,因此您必须在上下文文件中添加此架构的位置:

xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/jdbc
http://www.springframework.org/schema/jdbc/spring-jdbc-3.2.xsd
http://www.springframework.org/schema/data/jpa
http://www.springframework.org/schema/data/jpa/spring-jpa-1.3.xsd
http://www.springframework.org/schema/data/repository
http://www.springframework.org/schema/data/repository/spring-repository-1.5.xsd
http://www.springframework.org/schema/jee
http://www.springframework.org/schema/jee/spring-jee-3.2.xsd"

关于Spring-Data-JPA 使用 XML 配置在 Spring STS 中导致 XSD 验证错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14817565/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com