我是使用ElasticSearch Java API的新手,我想創建與我的實例的連接。ElasticSearch:安裝傳輸客戶端
我按照說明在這裏: getting started
,所以我得到了下面的代碼(如簡單的爲例!):
TransportClient mClient = new PreBuiltTransportClient(Settings.EMPTY)
.addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName("host1"),
9300));
但我面對有關導入類的問題: TransportClient和設置,了Eclipse找不到......
下面是行家進口:
<dependency>
<groupId>org.elasticsearch</groupId>
<artifactId>elasticsearch</artifactId>
<version>5.3.0</version>
</dependency>
<dependency>
<groupId>org.elasticsearch.client</groupId>
<artifactId>transport</artifactId>
<version>5.3.0</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>2.7</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.7</version>
</dependency>
我試圖尋找布特這個問題,但沒有找到解決辦法... Eclipse的發現沒有任何問題PreBuiltTransportClient。
這裏是MVN依賴的結果是:發球
[INFO]
[INFO] --- maven-dependency-plugin:2.8:tree (default-cli) @ poc ---
[INFO] fr.consortnt:poc:war:0.0.1-SNAPSHOT
[INFO] +- junit:junit:jar:3.8.1:test
[INFO] +- javax:javaee-web-api:jar:6.0:provided
[INFO] +- org.elasticsearch.client:transport:jar:5.3.0:compile
[INFO] | +- org.elasticsearch:elasticsearch:jar:5.3.0:compile
[INFO] | | +- org.apache.lucene:lucene-core:jar:6.4.1:compile
[INFO] | | +- org.apache.lucene:lucene-analyzers-common:jar:6.4.1:compile
[INFO] | | +- org.apache.lucene:lucene-backward-codecs:jar:6.4.1:compile
[INFO] | | +- org.apache.lucene:lucene-grouping:jar:6.4.1:compile
[INFO] | | +- org.apache.lucene:lucene-highlighter:jar:6.4.1:compile
[INFO] | | +- org.apache.lucene:lucene-join:jar:6.4.1:compile
[INFO] | | +- org.apache.lucene:lucene-memory:jar:6.4.1:compile
[INFO] | | +- org.apache.lucene:lucene-misc:jar:6.4.1:compile
[INFO] | | +- org.apache.lucene:lucene-queries:jar:6.4.1:compile
[INFO] | | +- org.apache.lucene:lucene-queryparser:jar:6.4.1:compile
[INFO] | | +- org.apache.lucene:lucene-sandbox:jar:6.4.1:compile
[INFO] | | +- org.apache.lucene:lucene-spatial:jar:6.4.1:compile
[INFO] | | +- org.apache.lucene:lucene-spatial-extras:jar:6.4.1:compile
[INFO] | | +- org.apache.lucene:lucene-spatial3d:jar:6.4.1:compile
[INFO] | | +- org.apache.lucene:lucene-suggest:jar:6.4.1:compile
[INFO] | | +- org.elasticsearch:securesm:jar:1.1:compile
[INFO] | | +- net.sf.jopt-simple:jopt-simple:jar:5.0.2:compile
[INFO] | | +- com.carrotsearch:hppc:jar:0.7.1:compile
[INFO] | | +- joda-time:joda-time:jar:2.9.5:compile
[INFO] | | +- org.yaml:snakeyaml:jar:1.15:compile
[INFO] | | +- com.fasterxml.jackson.core:jackson-core:jar:2.8.6:compile
[INFO] | | +- com.fasterxml.jackson.dataformat:jackson-dataformat-smile:jar:2.8.6:compile
[INFO] | | +- com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:jar:2.8.6:compile
[INFO] | | +- com.fasterxml.jackson.dataformat:jackson-dataformat-cbor:jar:2.8.6:compile
[INFO] | | +- com.tdunning:t-digest:jar:3.0:compile
[INFO] | | +- org.hdrhistogram:HdrHistogram:jar:2.1.6:compile
[INFO] | | \- net.java.dev.jna:jna:jar:4.2.2:compile
[INFO] | +- org.elasticsearch.plugin:transport-netty3-client:jar:5.3.0:compile
[INFO] | | \- io.netty:netty:jar:3.10.6.Final:compile
[INFO] | +- org.elasticsearch.plugin:transport-netty4-client:jar:5.3.0:compile
[INFO] | | +- io.netty:netty-buffer:jar:4.1.7.Final:compile
[INFO] | | +- io.netty:netty-codec:jar:4.1.7.Final:compile
[INFO] | | +- io.netty:netty-codec-http:jar:4.1.7.Final:compile
[INFO] | | +- io.netty:netty-common:jar:4.1.7.Final:compile
[INFO] | | +- io.netty:netty-handler:jar:4.1.7.Final:compile
[INFO] | | +- io.netty:netty-resolver:jar:4.1.7.Final:compile
[INFO] | | \- io.netty:netty-transport:jar:4.1.7.Final:compile
[INFO] | +- org.elasticsearch.plugin:reindex-client:jar:5.3.0:compile
[INFO] | | \- org.elasticsearch.client:rest:jar:5.3.0:compile
[INFO] | | +- org.apache.httpcomponents:httpclient:jar:4.5.2:compile
[INFO] | | +- org.apache.httpcomponents:httpcore:jar:4.4.5:compile
[INFO] | | +- org.apache.httpcomponents:httpasyncclient:jar:4.1.2:compile
[INFO] | | +- org.apache.httpcomponents:httpcore-nio:jar:4.4.5:compile
[INFO] | | +- commons-codec:commons-codec:jar:1.10:compile
[INFO] | | \- commons-logging:commons-logging:jar:1.1.3:compile
[INFO] | +- org.elasticsearch.plugin:lang-mustache-client:jar:5.3.0:compile
[INFO] | | \- com.github.spullara.mustache.java:compiler:jar:0.9.3:compile
[INFO] | \- org.elasticsearch.plugin:percolator-client:jar:5.3.0:compile
[INFO] +- org.apache.logging.log4j:log4j-api:jar:2.7:compile
[INFO] +- org.apache.logging.log4j:log4j-core:jar:2.7:compile
[INFO] +- taglibs:standard:jar:1.1.2:compile
[INFO] +- jstl:jstl:jar:1.2:runtime
[INFO] +- org.postgresql:postgresql:jar:9.4.1212:compile
[INFO] \- org.hibernate:hibernate-entitymanager:jar:4.2.15.Final:compile
[INFO] +- org.jboss.logging:jboss-logging:jar:3.1.0.GA:compile
[INFO] +- dom4j:dom4j:jar:1.6.1:compile
[INFO] +- org.javassist:javassist:jar:3.18.1-GA:compile
[INFO] +- org.jboss.spec.javax.transaction:jboss-transaction-api_1.1_spec:jar:1.0.1.Final:compile
[INFO] +- org.hibernate.javax.persistence:hibernate-jpa-2.0-api:jar:1.0.1.Final:compile
[INFO] +- org.hibernate.common:hibernate-commons-annotations:jar:4.0.2.Final:compile
[INFO] \- org.hibernate:hibernate-core:jar:4.2.15.Final:compile
[INFO] \- antlr:antlr:jar:2.7.7:compile
會發生什麼你知道嗎? 我敢肯定,它不是從maven配置的問題,因爲我可以從elasticsearch中導入一些所需的類...
在此先感謝!
該配置是好的,我沒有問題導入PostGreSQL類或其他,並且PrebuiltTransportClient正確導入沒有任何問題.... mvn乾淨安裝返回失敗,因爲缺少TransportClient – Aeldred