solr集成spring开发

一、

首先肯定是jar包的问题,不是简单的需要solrJ和solr-core就行了;

我就不分类了,如果你配置solr不成功,缺少这个类,然后又缺少那个类,不妨看看这几个包有没有加进去:

(1)、<groupId>commons-httpclient</groupId>
   <artifactId>commons-httpclient</artifactId>
   <version>3.1</version>

(2)、<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpcore</artifactId>
<version>4.4</version>

(3)、<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpmime</artifactId>
<version>4.4</version>

(4)、<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.3</version>

(5)、<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>

(6)、<groupId>taglibs</groupId>
<artifactId>standard</artifactId>
<version>1.1.2</version>

(7)、<groupId>org.apache.solr</groupId>
    <artifactId>solr-solrj</artifactId>
<version>5.0.0</version>

(8)、<groupId>org.apache.solr</groupId>
<artifactId>solr-core</artifactId>
<version>4.10.3</version>

(9)、<groupId>org.springframework.data</groupId>
 <artifactId>spring-data-solr</artifactId>
 <version>2.0.1.RELEASE</version>

(10)、<groupId>org.apache.solr</groupId>
<artifactId>solr-noggit</artifactId>
<version>3.2.0</version>

(11)、noggit-0.5.jar

二、

整合spring:写一个solr.xml 

<?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:solr="http://www.springframework.org/schema/data/solr"
       xsi:schemaLocation="http://www.springframework.org/schema/data/solr http://www.springframework.org/schema/data/solr/spring-solr.xsd
        http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
    
    
    <solr:solr-client id="solrClient" url="http://${solr.url}:8983/solr/jowto"/>
    
    <bean id="solrConverter" class="org.springframework.data.solr.core.convert.MappingSolrConverter">
<constructor-arg>
<bean class="org.springframework.data.solr.core.mapping.SimpleSolrMappingContext" />
</constructor-arg>
<property name="customConversions" ref="customConversions" />
</bean>


<bean id="customConversions" class="org.springframework.data.solr.core.convert.CustomConversions">
<!-- <constructor-arg>
<list>
<bean class="com.acme.MyBeanToSolrInputDocumentConverter"/>
</list>
</constructor-arg> -->
</bean>
    
    <bean id="solrTemplate" class="org.springframework.data.solr.core.SolrTemplate">
    <constructor-arg ref="solrClient"/>
    <property name="solrConverter" ref="solrConverter"></property>
    </bean>
</beans>

这些都是啥意思我还在研究,不过你已经可以使用solr开发了!

需要注意的是,好像solrJ4.x版本是用的solrServer,到solr5.x就是solrClient的了,其实是一样的,你可以看一下底层源码,不过版本不同,所依赖的jar包也不同!

三、

以上配置仅供参考!

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值