spring data jpa and commons compatibility

2.3k Views Asked by At

I meet an exception running a project using spring data jpa


org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 18 in XML document from class path resource [META-INF/applicationContext.xml] is invalid; nested exception is org.xml.sax.SAXParseException; systemId: http://www.springframework.org/schema/data/jpa/spring-jpa.xsd; lineNumber: 18; columnNumber: 51; src-resolve: Cannot resolve the name 'repository:repositories' to a(n) 'type definition' component.

I read through many docs and blogs and I think this is possibly caused by incompatibility of spring data jpa and spring data commons package versions.

Now I'm using

  • spring-data-commons-core-1.4.1.Release
  • spring-data-commons-1.10.0.release
  • spring-data-jpa-1.8.0.

Any suggestion on the version control to get rid of such error?

Also I would like to ask for suggestions how to make such version control easier(any website, docs or tools). Thanks for advice in advance.

Below is the namespace I use

<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:p="http://www.springframework.org/schema/p"
       xmlns:aop="http://www.springframework.org/schema/aop"
       xmlns:tx="http://www.springframework.org/schema/tx"
       xmlns:jpa="http://www.springframework.org/schema/data/jpa"
       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.xsd
       http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd
       http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd
       http://www.springframework.org/schema/data/jpa http://www.springframework.org/schema/data/jpa/spring-jpa.xsd
       http://www.springframework.org/schema/data/repository http://www.springframework.org/schema/data/repository/spring-repository.xsd">

The repository:repository is not from my applicationContext.xml. I did use jpa:repository as

<jpa:repositories base-package="com.canreef.calendar"/>
1

There are 1 best solutions below

2
On

I found this roots in spring-repository.xsd In spring-jpa.xsd there is a line with ref to repository:auditing-attributes:

<xsd:element name="auditing">
        <xsd:annotation>
            <xsd:appinfo>
                <tool:annotation>
                    <tool:exports type="org.springframework.data.jpa.domain.support.AuditingEntityListener" />
                    <tool:exports type="org.springframework.data.auditing.AuditingHandler" />
                </tool:annotation>
            </xsd:appinfo>
        </xsd:annotation>
        <xsd:complexType>
            <xsd:attributeGroup ref="repository:auditing-attributes" />
        </xsd:complexType>
    </xsd:element>

While in spring-repository.xsd there is the bean:

-<xsd:attributeGroup name="auditing-attributes">


-<xsd:attribute name="auditor-aware-ref">


-<xsd:annotation>


-<xsd:documentation>

<![CDATA[ References a bean of type AuditorAware to represent the current principal. ]]>

</xsd:documentation>


-<xsd:appinfo>


-<tool:annotation kind="ref">

<tool:assignable-to type="org.springframework.data.domain.AuditorAware"/>

</tool:annotation>

</xsd:appinfo>

</xsd:annotation>

</xsd:attribute>


...omitted...

</xsd:attributeGroup>

Therefore this should be caused by not able to fetch the repository.xsd.