<?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"
xmlns:context="http://www.springframework.org/schema/context"
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.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
<!-- 配置客户端连接 9100是head头插件的端口号,9200是界面操作连接端口号,9300是提供java,python语言操作的端口 toupdateXXXXX -->
<elasticsearch:transport-client
id="client" cluster-name="cy-es" cluster-nodes="192.168.236.110:9300"/>
<!-- 配置模板对象 -->
<bean id="elasticsearchTemplate"
class="org.springframework.data.elasticsearch.core.ElasticsearchTemplate">
<constructor-arg name="client" ref="client"/>
</bean>
<!-- 扫描DAO包 自动创建实现 toupdateXXXXX -->
<elasticsearch:repositories base-package="com.chaiyi.es"/>
</beans>
12-21
349
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountBlack.png)