ES实例化RestHighLevelClient时指定用户名和密码
ES实例化RestHighLevelClient时指定用户名和密码
·
参考代码
RestClientBuilder builder = RestClient.builder(new HttpHost(), port);
//开始设置用户名和密码
CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
credentialsProvider.setCredentials(AuthScope.ANY, new UsernamePasswordCredentials(username, password);
builder.setHttpClientConfigCallback(f -> f.setDefaultCredentialsProvider(credentialsProvider));
更多推荐
已为社区贡献12条内容
所有评论(0)