Spring集成elasticsearch

2017-01-23  本文已影响0人  抖抖村的抖抖

Artifacts

Usage

<?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:elasticsearch="http://www.springframework.org/schema/data/elasticsearch"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
       http://www.springframework.org/schema/beans/spring-beans.xsd
       http://www.springframework.org/schema/data/elasticsearch
       http://www.springframework.org/schema/data/elasticsearch/spring-elasticsearch-1.0.xsd">
    <bean class="org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor"/>

    <elasticsearch:repositories base-package="com.doudou.demo.repositories"/>
    <!--通过transport方式与ES集群通信,不需要在本地创建节点-->
    <!--client-transport-sniff表示是否进行自动嗅探ES集群中节点-->
    <elasticsearch:transport-client id="es.transport.client"
                                    cluster-nodes="177.177.177.177:9300,177.177.177.176:9300"
                                    cluster-name="DouDouCluster"
                                    client-transport-sniff="false"/>
    <bean name="elasticsearchTemplate" class="org.springframework.data.elasticsearch.core.ElasticsearchTemplate">
        <constructor-arg name="client" ref="es.transport.client"/>
    </bean>
    <bean id="simpleElasticsearchRepository"
          class="org.springframework.data.elasticsearch.repository.support.SimpleElasticsearchRepository">
        <constructor-arg name="elasticsearchOperations" ref="elasticsearchTemplate"/>
    </bean>
</beans>
上一篇 下一篇

猜你喜欢

热点阅读