如何从jar-with-dependency中删除一个类

时间:2019-02-01 09:53:30

标签: maven maven-assembly-plugin

我有一个使用/org/elasticsearch/client/RestHighLevelClient.class连接到ElasticSearch的应用程序。但是我也想使用另一个也使用RestHighLevelClient.class的库。可悲的是,我在pom.xml中将其作为<classifier>jar-with-dependencies</classifier>。如何交换它们?

这是我的pom

 <dependency>
        <groupId>org.elasticsearch.client</groupId>
        <artifactId>elasticsearch-rest-high-level-client</artifactId>
        <version>6.4.3</version>
    </dependency>
    <dependency>
        <groupId>org.elasticsearch</groupId>
        <artifactId>elasticsearch</artifactId>
        <version>6.4.3</version>
    </dependency>
    <dependency>
        <groupId>com.another-library</groupId>
        <artifactId>another-artifact</artifactId>
        <version>1.1.3</version>
        <classifier>jar-with-dependencies</classifier>
    </dependency>

当我想使用RestHighLevelCleint类时,会出现此异常

***************************
APPLICATION FAILED TO START
***************************

Description:

An attempt was made to call the method org.elasticsearch.client.RestHighLevelClient.<init>(Lorg/elasticsearch/client/RestClient;)V but it does not exist. Its class, org.elasticsearch.client.RestHighLevelClient, is available from the following locations:

jar:file:/C:/Users/lolek/.m2/repository/org/elasticsearch/client/elasticsearch-rest-high-level-client/6.4.3/elasticsearch-rest-high-level-client-6.4.3.jar!/org/elasticsearch/client/RestHighLevelClient.class
jar:file:/C:/Users/lolek/.m2/repository/another-library/another-artifact/1.1.3/another-artifact-1.1.3-jar-with-dependencies.jar!/org/elasticsearch/client/RestHighLevelClient.class

It was loaded from the following location:

file:/C:/Users/lolek/.m2/repository/org/elasticsearch/client/elasticsearch-rest-high-level-client/6.4.3/elasticsearch-rest-high-level-client-6.4.3.jar


Action:

Correct the classpath of your application so that it contains a single, compatible version of org.elasticsearch.client.RestHighLevelClient

0 个答案:

没有答案