使用idea:javaAPI往公司ES集群批量随机生成索引,用于ES节点的压测,报错:org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name
报错情况:
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name '**********’......
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'org.elasticsearch.client.RestHighLevelClient' available: expected at least 1 bean......
bug修复后成果效果如下:
原因:javaAPI连接公司es节点,能连上,但是无法进行增删改查,原因是公司es集群有ssl安全协议,使用http无法连接,要使用https,具体过程如下:
import org.apache.http.HttpHost;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestHighLevelClient;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.elasticsearch.client.ClientConfiguration;
import org.springframework.data.elasticsearch.client.RestClients;
import org.springframework.data.elasticsearch.config.AbstractElasticsearchConfiguration;
import org.springframework.stereotype.Component;`
@Component
@Configuration
@ConfigurationPropert