在模块中找到重复的类 [英] Duplicates class found in modules

查看:58
本文介绍了在模块中找到重复的类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在模块jsp-api-2.1-6.1.14.jar(org.mortbay.jetty:jsp-api-2.1:6.1.14)和jsp-api-2.1.jar(javax.servlet.jsp:jsp-api:2.1)在模块jsp-api-2.1-6.1.14.jar(org.mortbay.jetty:jsp-api-2.1:6.1.14)和jsp-api-2.1.jar(javax.servlet)中找到重复的类javax.el.BeanELResolver.jsp:jsp-api:2.1)在模块jsp-api-2.1-6.1.14.jar(org.mortbay.jetty:jsp-api-2.1:6.1.14)和jsp-api-2.1.jar(javax)中找到重复的类javax.el.BeanELResolver $ BeanProperties.servlet.jsp:jsp-api:2.1)在模块jsp-api-2.1-6.1.14.jar(org.mortbay.jetty:jsp-api-2.1:6.1.14)和jsp-api-2.1.jar(javax)中找到重复的类javax.el.BeanELResolver $ BeanProperty.servlet.jsp:jsp-api:2.1)

Duplicate class javax.el.ArrayELResolver found in modules jsp-api-2.1-6.1.14.jar (org.mortbay.jetty:jsp-api-2.1:6.1.14) and jsp-api-2.1.jar (javax.servlet.jsp:jsp-api:2.1) Duplicate class javax.el.BeanELResolver found in modules jsp-api-2.1-6.1.14.jar (org.mortbay.jetty:jsp-api-2.1:6.1.14) and jsp-api-2.1.jar (javax.servlet.jsp:jsp-api:2.1) Duplicate class javax.el.BeanELResolver$BeanProperties found in modules jsp-api-2.1-6.1.14.jar (org.mortbay.jetty:jsp-api-2.1:6.1.14) and jsp-api-2.1.jar (javax.servlet.jsp:jsp-api:2.1) Duplicate class javax.el.BeanELResolver$BeanProperty found in modules jsp-api-2.1-6.1.14.jar (org.mortbay.jetty:jsp-api-2.1:6.1.14) and jsp-api-2.1.jar (javax.servlet.jsp:jsp-api:2.1)

 build.gradle:
    implementation fileTree(dir: 'libs', include: ['*.jar'])
        implementation 'androidx.appcompat:appcompat:1.1.0'
        implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
        testImplementation 'junit:junit:4.12'
        androidTestImplementation 'androidx.test.ext:junit:1.1.1'
        androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
        //The dependencies below are for a library i'm including after which i get the error
        compile "org.bouncycastle:bcprov-jdk15on:1.54"
        compile "org.apache.pdfbox:pdfbox:[2.0.15,)"
        compile "org.mapdb:mapdb:3.0.4"
        compile "com.google.guava:guava:19.0"
        compile "com.carrotsearch:java-sizeof:0.0.5"
        compile "org.apache.hadoop:hadoop-common:2.7.1"
        compile "com.amazonaws:aws-java-sdk:1.11.19"
        compile "org.apache.hadoop:hadoop-core:1.2.1"
        compile "org.apache.lucene:lucene-analyzers-common:6.1.0"
        compile "org.apache.poi:poi-scratchpad:3.15-beta1"
        compile "org.apache.poi:poi:3.15-beta1"
        compile "org.apache.poi:poi-ooxml:3.15-beta1"

我已经读过栈溢出上的其他线程,它们关于在build.gradle中使用exclude:group,只是我似乎做错了什么.有人可以告诉我(i)如何添加排除语句来解决上述错误,而不是给出一些通用示例(ii)我将如何手动删除导致重复的模块?(我尝试过从gradle缓存文件夹中删除它们,甚至删除了.gradle文件夹,但它一直在重建它).任何建议将不胜感激

I've read on other threads on stack overflow about using the exclude:group in your build.gradle it's just that i seem to be doing something wrong. Can someone please tell me (i) how to add the exlude statement to the fix the error above instead of giving some generic example (ii) how would i manually remove the modules causing the duplication? (i've tried by removing them from the gradle cache folder even deleted the .gradle folder but it keeps rebuilding it). Any suggestion would be appreciated

推荐答案

首先,不建议将编译替换为实现.(i)该链接提供了很好的解释: https://discuss.gradle.org/t/how-to-exclude-transitive-dependency/2119/2 (ii)我进行了很多搜索,以找到可行的方法来进行此操作,并且大多数建议的方法都失败了.实际起作用的是以下示例:注意:程序类的重复定义问题:hadoop-common和hadoop-core共享许多导致冲突的通用类解决方案:我设法通过手动删除jar文件中的重复.class文件来解决此问题.(IE.(i)将扩展名从jar更改为zip(ii)提取(iii)删除.class文件或整个文件夹(如果其中包含所有重复文件)(iv)将扩展名从zip更改回jar请注意,不要使用Winrar解压缩jar文件并尝试将其压缩回去,因为某些奇怪的原因不起作用.我不得不导航到Gradle缓存:C->用户->用户名-> .gradle->缓存-> modules-2-> files-2-> org.apache.hadoop->找到hadoop-common或hadoop-core,然后应用以上内容删除具有重复类的文件夹

Firstly compile should be replaced with implementation as it is deprecated. (i) this link provides a good explanation: https://discuss.gradle.org/t/how-to-exclude-transitive-dependency/2119/2 (ii) I searched a lot to find a workable way to go about doing this and most of the suggested methods failed. What actually worked was the following example: Note: duplicate definition of program class Problem: hadoop-common and hadoop-core shared numerous common classes that were causing conflict Solution: I managed to solve it by manually removing the duplicate .class files in the jar file. (i.e. (i) changing the extension from jar to zip (ii) extract it (iii) remove the .class files or the entire folder if it contains all the duplicate files (iv) change the extension from zip back to jar Note do not extract the jar files with Winrar and try to zip them back, for some odd reason that doesn't work. I had to navigate to the Gradle cache: C->Users-> Username -> .gradle -> caches -> modules-2 -> files-2 -> org.apache.hadoop -> find either hadoop-common or hadoop-core and apply the above to delete the folders with duplicate classes

这篇关于在模块中找到重复的类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆