[英]Exception when using google guava and google collections at once
我的Java代碼取決於2個庫A和B
A依賴於GoogleCollections B依賴於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)
我怎么解決這個問題?
如果幸運的話...。僅包含您依賴的包含ImmutableList的GoogleCollections的最新版本。
Google收藏集已過時,已移至Guava。 從A中排除它。使用Maven,可以使用項目 POM中依賴項標簽下面的exclusions標簽進行操作:
<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>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.