日期:2014-05-16  浏览次数:21043 次

spring-data-JPA和spring-data-mongodb依赖包版本冲突解决办法

项目之前用的spring-data-jpa,版本是1.1.0.RELEASE,依赖关系如下:

?

<dependency>
	<groupId>org.springframework.data</groupId>
	<artifactId>spring-data-jpa</artifactId>
	<version>1.1.0.RELEASE</version>
</dependency>

?后由于业务扩展,需要增加mongodb,采用关系型数据库和nosql联合持久化,因此加入了spring-data-mongodb,当前最新版本是1.2.0.RELEASE,依赖关系如下:

?

?

<dependency>
	<groupId>org.springframework.data</groupId>
	<artifactId>spring-data-mongodb</artifactId>
	<version>1.2.0.RELEASE</version>
</dependency>

?添加后启动项目,Spring配置检查失败,报错如下:

?

org.xml.sax.SAXParseException: src-resolve: Cannot resolve the name 'repository:repository' to a(n) 'type definition' component.
??? at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
??? at org.apache.xerces.util.ErrorHandlerWrapper.error(Unknown Source)
??? at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
??? at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
??? at org.apache.xerces.impl.xs.traversers.XSDHandler.reportSchemaError(Unknown Source)
??? at org.apache.xerces.impl.xs.traversers.XSDHandler.getGlobalDecl(Unknown Source)
??? at org.apache.xerces.impl.xs.traversers.XSDComplexTypeTraverser.traverseComplexContent(Unknown Source)
??? at org.apache.xerces.impl.xs.traversers.XSDComplexTypeTraverser.traverseComplexTypeDecl(Unknown Source)
??? at org.apache.xerces.impl.xs.traversers.XSDComplexTypeTraverser.traverseGlobal(Unknown Source)
??? at org.apache.xerces.impl.xs.traversers.XSDHandler.traverseSchemas(Unknown Source)
??? at org.apache.xerces.impl.xs.traversers.XSDHandler.parseSchema(Unknown Source)
??? at org.apache.xerces.impl.xs.XMLSchemaLoader.loadSchema(Unknown Source)
??? at org.apache.xerces.impl.xs.XMLSchemaValidator.findSchemaGrammar(Unknown Source)
??? at org.apache.xerces.impl.xs.XMLSchemaValidator.handleStartElement(Unknown Source)
??? at org.apache.xerces.impl.xs.XMLSchemaValidator.emptyElement(Unknown Source)
??? at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source)
??? at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
??? at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
??? at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
??? at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
??? at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
??? at org.apache.xerces.parsers.DOMParser.parse(Unknown Source)
??? at org.apache.xerces.jaxp.DocumentBuilderImpl.parse(Unknown Source)
??? at org.springframework.beans.factory.xml.DefaultDocumentLoader.loadDocument(DefaultDocumentLoader.java:75)
??? at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:388)
??? at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:334)
??? at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:302)
??? at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:174)
??? at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:209)
??? at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:180)
??? at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:125)<