赞
踩
原文链接:https://blog.csdn.net/magic_1024/article/details/103246719
如果你的 es 和 redis 版本冲突了,试试更高版本的 netty:
<!-- 解决 mq 和 es 的冲突 -->
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-all</artifactId>
<version>4.1.68.Final</version>
</dependency>
1.添加spring-data-elasticsearch依赖
<!--elasticsearch-->
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-elasticsearch</artifactId>
<version>3.2.1.RELEASE</version>
</dependency>
2.application.properties添加ElasticSearch连接信息
#Elasticsearch配置
elasticsearch.host=127.0.0.1
elasticsearch.port=9200
3.创建Elasticsearch配置类
package com.example.demo.config; import lombok.extern.slf4j.Slf4j; import org.elasticsearch.client.Client; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.transport.TransportAddress; import org.elasticsearch.transport.client.PreBuiltTransportClient; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.data.elasticsearch.core.ElasticsearchOperations; import org.springframework.data.elasticsearch.core.ElasticsearchTemplate; import org.springframework.data.elasticsearch.repository.config.EnableElasticsearchRepositories; import java.net.InetAddress; @Slf4j @Configuration @EnableElasticsearchRepositories(basePackages = "com.example.demo.dao") public class ElasticsearchConfig { @Value("${elasticsearch.host}") private String esHost; @Value("${elasticsearch.port}") private int esPort; @Value(
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。