如何集成spring数据jpa和spring数据solr?
为了启用全文搜索,我曾经使用过hibernate搜索和solrJ,不,我正在尝试SpringDataSolr,但发现我似乎没有与SpringDataJPA一起工作。我就是不能使配置正确。如果我将以下solr配置xml添加到我的项目中,我会收到错误消息。 spring data solr的配置xml文件为:如何集成spring数据jpa和spring数据solr?,solr,spring-data,spring-data-jpa,spring-data-solr,Solr,Spring Data,Spring Data Jpa,Spring Data Solr,为了启用全文搜索,我曾经使用过hibernate搜索和solrJ,不,我正在尝试SpringDataSolr,但发现我似乎没有与SpringDataJPA一起工作。我就是不能使配置正确。如果我将以下solr配置xml添加到我的项目中,我会收到错误消息。 spring data solr的配置xml文件为: <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org
<?xml version="1.0" encoding="UTF-8"?>
<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:context="http://www.springframework.org/schema/context"
xmlns:solr="http://www.springframework.org/schema/data/solr" xmlns:util="http://www.springframework.org/schema/util" xmlns:cache="http://www.springframework.org/schema/cache" xmlns:security="http://www.springframework.org/schema/security"
xsi:schemaLocation="http://www.springframework.org/schema/data/solr http://www.springframework.org/schema/data/solr/spring-solr-1.0.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/cache http://www.springframework.org/schema/cache/spring-cache.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd
http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security.xsd">
<!--
#####################################
CONTEXT SETTINGS
#####################################
-->
<context:property-placeholder location="classpath:laa.properties" ignore-resource-not-found="true" />
<!--
#####################################
SOLR
#####################################
-->
<solr:solr-server id="solrServer" url="${solr.host}" />
<bean id="solrTemplate" class="org.springframework.data.solr.core.SolrTemplate" scope="singleton">
<constructor-arg ref="solrServer" />
</bean>
</beans>
类路径上缺少Spring数据共享。请看另一个问题。我已经将SpringDataCommonsCore添加到pom.xml文件中。在此之前,maven构建得到了ClassNotFoundException。您参考了哪些版本?Spring Data JPA 1.2.0.RELEASE和Spring Data Solr 1.0.0.M1都引用Spring Data Commons 1.4.0.RELEASE,应该在不需要显式声明的情况下提取依赖项。在我将Spring Data JPA的版本从1.1.0.RELEASE更改为1.2.0.RELEASE之后。看来问题解决了。但还有一个例外。
org.xml.sax.SAXParseException; systemId: http://www.springframework.org/schema/data/jpa/spring-jpa.xsd; lineNumber: 18; columnNumber: 48; 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.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)