setup-xclient.asciidoc 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. [role="xpack"]
  2. [testenv="basic"]
  3. [[setup-xpack-client]]
  4. == Configuring {xpack} Java Clients
  5. deprecated[7.0.0, The `TransportClient` is deprecated in favour of the {java-rest}/java-rest-high.html[Java High Level REST Client] and will be removed in Elasticsearch 8.0. The {java-rest}/java-rest-high-level-migration.html[migration guide] describes all the steps needed to migrate.]
  6. If you want to use a Java {javaclient}/transport-client.html[transport client] with a
  7. cluster where {xpack} is installed, then you must download and configure the
  8. {xpack} transport client.
  9. . Add the {xpack} transport JAR file to your *CLASSPATH*. You can download the {xpack}
  10. distribution and extract the JAR file manually or you can get it from the
  11. https://artifacts.elastic.co/maven/org/elasticsearch/client/x-pack-transport/{version}/x-pack-transport-{version}.jar[Elasticsearch Maven repository].
  12. As with any dependency, you will also need its transitive dependencies. Refer to the
  13. https://artifacts.elastic.co/maven/org/elasticsearch/client/x-pack-transport/{version}/x-pack-transport-{version}.pom[X-Pack POM file
  14. for your version] when downloading for offline usage.
  15. . If you are using Maven, you need to add the {xpack} JAR file as a dependency in
  16. your project's `pom.xml` file:
  17. +
  18. --
  19. [source,xml]
  20. --------------------------------------------------------------
  21. <project ...>
  22. <repositories>
  23. <!-- add the elasticsearch repo -->
  24. <repository>
  25. <id>elasticsearch-releases</id>
  26. <url>https://artifacts.elastic.co/maven</url>
  27. <releases>
  28. <enabled>true</enabled>
  29. </releases>
  30. <snapshots>
  31. <enabled>false</enabled>
  32. </snapshots>
  33. </repository>
  34. ...
  35. </repositories>
  36. ...
  37. <dependencies>
  38. <!-- add the x-pack jar as a dependency -->
  39. <dependency>
  40. <groupId>org.elasticsearch.client</groupId>
  41. <artifactId>x-pack-transport</artifactId>
  42. <version>{version}</version>
  43. </dependency>
  44. ...
  45. </dependencies>
  46. ...
  47. </project>
  48. --------------------------------------------------------------
  49. --
  50. . If you are using Gradle, you need to add the {xpack} JAR file as a dependency in
  51. your `build.gradle` file:
  52. +
  53. --
  54. [source,groovy]
  55. --------------------------------------------------------------
  56. repositories {
  57. /* ... Any other repositories ... */
  58. // Add the Elasticsearch Maven Repository
  59. maven {
  60. name "elastic"
  61. url "https://artifacts.elastic.co/maven"
  62. }
  63. }
  64. dependencies {
  65. compile "org.elasticsearch.client:x-pack-transport:{version}"
  66. /* ... */
  67. }
  68. --------------------------------------------------------------
  69. --
  70. . If you are using a repository manager such as https://www.sonatype.com/nexus-repository-oss[Nexus OSS] within your
  71. company, you need to add the repository as per the following screenshot:
  72. +
  73. --
  74. image::security/images/nexus.png["Adding the Elastic repo in Nexus",link="images/nexus.png"]
  75. Then in your project's `pom.xml` if using maven, add the following repositories and dependencies definitions:
  76. [source,xml]
  77. --------------------------------------------------------------
  78. <dependencies>
  79. <dependency>
  80. <groupId>org.elasticsearch.client</groupId>
  81. <artifactId>x-pack-transport</artifactId>
  82. <version>{version}</version>
  83. </dependency>
  84. </dependencies>
  85. <repositories>
  86. <repository>
  87. <id>local-nexus</id>
  88. <name>Elastic Local Nexus</name>
  89. <url>http://0.0.0.0:8081/repository/elasticsearch/</url>
  90. <releases>
  91. <enabled>true</enabled>
  92. </releases>
  93. <snapshots>
  94. <enabled>false</enabled>
  95. </snapshots>
  96. </repository>
  97. </repositories>
  98. --------------------------------------------------------------
  99. --