本来版本7.4.0不行,最后换了个版本7.15.1就可以了,但又出现以下问题了:
@Beanpublic ElasticsearchClient elasticsearchClient() {
// RestClient client = RestClient.builder(new HttpHost("localhost", 9200,"http")).build();RestClient client = RestClient.builder(new HttpHost("192.168.101.128", 9200, "http")).setDefaultHeaders(new Header[]{new BasicHeader("Content-type", "application/json"),new BasicHeader("X-Elastic-Product", "Elasticsearch")}).build();ElasticsearchTransport transport = new RestClientTransport(client, new JacksonJsonpMapper());return new ElasticsearchClient(transport);}
"Elasticsearch built-in security features are not enabled. Without authentication, your cluster could be accessible to anyone. See https://www.elastic.co/guide/en/elasticsearch/reference/7.13/security-minimal-setup.html to enable security."
elasticsearch.yml配置:xpack.security.enabled: false