码迷,mamicode.com
首页 > 其他好文 > 详细

使用RestHighLevelClient 连接带有用户名密码ES机器

时间:2020-04-12 16:32:01      阅读:827      评论:0      收藏:0      [点我收藏+]

标签:any   pcl   password   tco   lsp   ack   有用   res   als   

HttpHost host=new HttpHost(“IP地址”, “端口号”, HttpHost.DEFAULT_SCHEME_NAME);
RestClientBuilder builder=RestClient.builder(host);
CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
credentialsProvider.setCredentials(AuthScope.ANY, new UsernamePasswordCredentials(“用户名”, “密码”));
builder.setHttpClientConfigCallback(f -> f.setDefaultCredentialsProvider(credentialsProvider));
RestHighLevelClient restClient = new RestHighLevelClient( builder);

使用RestHighLevelClient 连接带有用户名密码ES机器

标签:any   pcl   password   tco   lsp   ack   有用   res   als   

原文地址:https://www.cnblogs.com/pxinhai/p/12685424.html

(0)
(1)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!