我已经在我的elasticsearch:curl --user u:p 'localhost:9200/_xpack'中安装了x-pack
{
"build" : {
"hash" : "e016ba5",
"date" : "2017-01-24T20:17:08.168Z"
},
"license" : {
"uid" : "a5a93479-cdd1-44c0-8669-78a3ae1cbfeb",
"type" : "trial",
"mode" : "trial",
"status" : "active",
"expiry_date_in_millis" : 1491567639615
},
"features" : {
"graph" : {
"description" : "Graph Data Exploration for the Elastic Stack",
"available" : true,
"enabled" : false
},
"monitoring" : {
"description" : "Monitoring for the Elastic Stack",
"available" : true,
"enabled" : false
},
"security" : {
"description" : "Security for the Elastic Stack",
"available" : true,
"enabled" : true
},
"watcher" : {
"description" : "Alerting, Notification and Automation for the Elastic Stack",
"available" : true,
"enabled" : false
}
},
"tagline" : "You know, for X"
}为了构建我的客户端,这是我的代码:
Settings settings = Settings.builder()
.put(ElasticsearchApplicationResources.ELASTICSEARCH_PROPERTY_CLUSTER_NAME, this.configurationResources.getElasticsearchCluserName())
.put("xpack.security.user", "elastic:changeme")
.build();
List<InetSocketTransportAddress> addresses = ...;
try {
this.elasticsearchClient = new PreBuiltTransportClient(settings)
.addTransportAddresses(addresses.toArray(new InetSocketTransportAddress[addresses.size()]));
}catch (Exception e)
{
System.out.print(e);
}目前,我收到这样的信息:
java.lang.IllegalArgumentException:未知设置xpack.security.user请检查是否安装了所需的插件,或检查删除设置的中断更改文档
有什么想法吗?
发布于 2017-06-12 07:35:27
那么,您需要在“pom.xml”中添加此依赖项
<repositories>
<!-- add the elasticsearch repo -->
<repository>
<id>elasticsearch-releases</id>
<url>https://artifacts.elastic.co/maven</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
<dependency>
<groupId>org.elasticsearch.client</groupId>
<artifactId>x-pack-transport</artifactId>
<version>${org.elasticsearch.version}</version>
</dependency>接下来,更新java代码,
import org.elasticsearch.xpack.client.PreBuiltXPackTransportClient;
this.elasticsearchClient = new PreBuiltXPackTransportClient(settings)
.addTransportAddresses(addresses.toArray(new InetSocketTransportAddress[addresses.size()]));然后再试一次~
https://stackoverflow.com/questions/42787019
复制相似问题