Вопрос

My java code is dependent on 2 libraries A and B

A has a dependency on GoogleCollections B has a dependency GoogleGuava r10;

Now when i build  my code everything works fine.But when i run i get following exception

java.lang.NoSuchMethodError: com.google.common.collect.ImmutableList.copyOf([Ljava/lang/Object;)Lcom/google/common/collect/ImmutableList;
    at com.abc.Pqr$Builder.withXYZ(ExponentialBackoffRetryPolicy.java:329)

How can i solve this problem?

Это было полезно?

Решение

Google Collections has been deprecated and moved into Guava. Exclude it from A. With Maven, you do that with the exclusions tag below the dependency tag in your project's POM:

    <dependency>
        <groupId>org.project</groupId>
        <artifactId>library-a</artifactId>
        <version>[version]</version>
        <exclusions>
            <exclusion>
                <!-- whatever the correct values are -->
                <artifactId>google-collections</artifactId>
                <groupId>google-collections</groupId>
            </exclusion>
        </exclusions>
    </dependency>

Другие советы

If your lucky.... include only the most recent version version of GoogleCollections that contains ImmutableList that you depend upon..

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top