【发布时间】:2015-05-28 08:59:40
【问题描述】:
我遇到了一个使用 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.
我阅读了许多文档和博客,我认为这可能是由于 spring data jpa 和 spring data commons 包版本不兼容造成的。
现在我正在使用
- spring-data-commons-core-1.4.1.Release
- spring-data-commons-1.10.0.release
- 弹簧数据-jpa-1.8.0。
对版本控制有什么建议可以消除此类错误吗?
另外,我想请教如何使此类版本控制更容易(任何网站、文档或工具)。提前感谢您的建议。
下面是我使用的命名空间
<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">
repository:repository 不是来自我的applicationContext.xml。我确实使用jpa:repository作为
<jpa:repositories base-package="com.canreef.calendar"/>
【问题讨论】:
-
-
我确实使用了 jpa:repository
-
@Deinum 我确实使用了 jpa:repository,那个 repository:repository 必须来自一个 xml。我已经添加到帖子中,请检查。
-
如前所述,不要自己搜索依赖项,使用 maven 为您做这件事...为您省去了很多麻烦。删除
spring-data-commons-corejar,因为它已经很旧了,真的很旧......还有,为什么你的声明中需要spring-repository.xsd?如果您不使用它,只需将其删除。 -
@Deinum 感谢您的建议,但不幸的是,删除 repository.xsd 依赖项并没有帮助。我在命名空间中删除了与存储库相关的条目,但异常是相同的。
标签: spring jpa version-control spring-data-jpa spring-data-commons