Today I try to use the elasticsearch client to access elasticsearch. Its client provides more functionality than writing REST calls yourself, as follows:
Failed to reconnect to the server.
Failover Rescue (HA)
load balancing.
Reference address: https://www.elastic.co/guide/en/elasticsearch/client/java-rest/current/java-rest-low.html
There is a section in its documentation dedicated to the conflict between its jar and other jars. I think the method it said is not very effective. After thinking about it, the solution is as follows:
Enter elasticsearch's own local maven repository path, such as:
/maven/maven_repository/org/elasticsearch/client/elasticsearch-rest-client/5.6.2
Check out its project's original maven dependency file: elasticsearch-rest-client-5.6.2.pom
Check how the dependencies in this file are configured, paste these dependencies into your own pom.xml, and then remove the dependencies of your conflicting jars (if your previous dependencies cannot be changed, refer to the official website). Dependency conflict resolution bar), and that's it.