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

时间:2013-02-11 17:33:15

标签: spring spring-data-jpa

Eclipse / STS使用Spring 3.2.1与Spring-data-jpa一起报告错误。 我有一些带有以下标题的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-Data-JPA 1.3.0中使用Spring 3.2.1,而Eclipse / STS正在报告这个:

  

引用文件包含错误   (http://www.springframework.org/schema/data/jpa

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

我的配置是错误的还是会发生什么?

谢谢! 保罗

1 个答案:

答案 0 :(得分:6)

今天没有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"