我在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>
但我得到了例外:
嵌套异常是org.xml.sax.SAXParseException:cvc-complex-type.2.4.a:找到以元素&#39; jpa:repository&#39;开头的无效内容。 &#39; {&#34; http://www.springframework.org/schema/data/repository" ;:include-filter,&#34; http://www.springframework.org/schema/数据/库&#34;:排除滤波器}&#39;是预期的。
答案 0 :(得分:3)
简而言之,如果您将http://www.springframework.org/schema/data/jpa/spring-jpa.xsd
替换为http://www.springframework.org/schema/data/jpa/spring-jpa-1.1.xsd
,它将解决问题。但我不确定你是否愿意这样做。
原因?在新的spring-data-jpa版本中删除了标记<jpa:repository id="articleDao" repository-impl-ref="articleDaoPlus" />
。
看看两个xsds之间的差异,即http://www.springframework.org/schema/data/jpa/spring-jpa.xsd
和http://www.springframework.org/schema/data/jpa/spring-jpa-1.1.xsd