zoukankan      html  css  js  c++  java
  • ES7.6.1 配置x-path后 连接java客户端

    装了x-pack插件后,需要填写x-pack相关的设置,

     Settings settings = Settings.builder(). put("xpack.security.user", "elastic:changeme").build();
           client = new PreBuiltXPackTransportClient(settings)
                   .addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName("localhost"), 9300));
           elasticsearchTemplate = new ElasticsearchTemplate(client);
           final CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
           credentialsProvider.setCredentials(AuthScope.ANY,
                   new UsernamePasswordCredentials("elastic", "changeme"));
           restClient = RestClient.builder(new HttpHost("localhost",9200,"http"))
                   .setHttpClientConfigCallback(new RestClientBuilder.HttpClientConfigCallback() {
                       @Override
                       public HttpAsyncClientBuilder customizeHttpClient(HttpAsyncClientBuilder httpClientBuilder) {
                           return httpClientBuilder.setDefaultCredentialsProvider(credentialsProvider);
                       }
                   }).build();

    https://discuss.elastic.co/t/none-of-the-configured-nodes-are-available-5-5-0/94951/5

  • 相关阅读:
    File
    多态
    方法重载
    Math
    instanceof
    强制类型转换
    泛型
    springboot热部署
    iOS bug处理
    iOS8-xcode6中添加pch全局引用文件
  • 原文地址:https://www.cnblogs.com/1394htw/p/12816828.html
Copyright © 2011-2022 走看看