简体   繁体   中英

Invalid content was found starting with element 'jpa:repository'

I use this in spring-data-jpa:

<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:jee="http://www.springframework.org/schema/jee"
xmlns:tx="http://www.springframework.org/schema/tx" xmlns:jpa="http://www.springframework.org/schema/data/jpa"
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/jee http://www.springframework.org/schema/jee/spring-jee-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/jpa http://www.springframework.org/schema/data/jpa/spring-jpa.xsd"
default-lazy-init="true">

<jpa:repositories base-package="org.kb" repository-impl-postfix="Impl">
<jpa:repository id="articleDao" repository-impl-ref="articleDaoPlus" /> 
</jpa:repositories>

but i got the exception:

nested exception is org.xml.sax.SAXParseException: cvc-complex-type.2.4.a: Invalid content was found starting with element 'jpa:repository'. One of '{"http://www.springframework.org/schema/data/repository":include-filter, "http://www.springframework.org/schema/data/repository":exclude-filter}' is expected.

In short if your replace http://www.springframework.org/schema/data/jpa/spring-jpa.xsd with http://www.springframework.org/schema/data/jpa/spring-jpa-1.1.xsd , it will solve the problem. But I am not sure you would want to do that.

Reason? Tag <jpa:repository id="articleDao" repository-impl-ref="articleDaoPlus" /> is removed in the new spring-data-jpa version.

Have a look at the difference between the two xsds ie http://www.springframework.org/schema/data/jpa/spring-jpa.xsd and http://www.springframework.org/schema/data/jpa/spring-jpa-1.1.xsd

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM