欢迎来到尧图网

客户服务 关于我们

您的位置:首页 > 科技 > 能源 > spark,poi,jar包冲突(commons.io)

spark,poi,jar包冲突(commons.io)

2025/2/24 18:14:58 来源:https://blog.csdn.net/qq_40382400/article/details/142533341  浏览:    关键词:spark,poi,jar包冲突(commons.io)

1.查看报错类是属于哪个jar包

System.out.println("ZipArchiveInputStream类是:" + ZipArchiveInputStream.class.getProtectionDomain().getCodeSource().getLocation());
System.out.println("UnsynchronizedByteArrayOutputStream 类是:" + UnsynchronizedByteArrayOutputStream.class.getProtectionDomain().getCodeSource().getLocation());
System.out.println("IOUtils 类是:" + IOUtils.class.getProtectionDomain().getCodeSource().getLocation());

2.使用shade来打包并隔离依赖,就是重命名包名

<plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-shade-plugin</artifactId><version>3.2.4</version><executions><execution><phase>package</phase><goals><goal>shade</goal></goals><configuration><relocations><relocation><pattern>org.apache.commons.io</pattern><shadedPattern>myshade.org.apache.commons.io</shadedPattern></relocation></relocations></configuration></execution></executions>
</plugin>

3.排除jar包

<dependency><groupId>org.apache.spark</groupId><artifactId>spark-core_${scala.version}</artifactId><version>${spark.version}</version><exclusions><exclusion><artifactId>jackson-annotations</artifactId><groupId>com.fasterxml.jackson.core</groupId></exclusion><exclusion><artifactId>jackson-core</artifactId><groupId>com.fasterxml.jackson.core</groupId></exclusion><exclusion><artifactId>jackson-databind</artifactId><groupId>com.fasterxml.jackson.core</groupId></exclusion><exclusion><artifactId>jackson-module-scala_2.11</artifactId><groupId>com.fasterxml.jackson.module</groupId></exclusion><exclusion><artifactId>commons-compress</artifactId><groupId>org.apache.commons</groupId></exclusion></exclusions>
<!--            <scope>provided</scope>-->
</dependency>

4.引入jar包

<dependency><groupId>commons-io</groupId><artifactId>commons-io</artifactId><version>2.17.0</version>
</dependency>
<dependency><groupId>org.apache.commons</groupId><artifactId>commons-compress</artifactId><version>1.18</version>
</dependency>

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

热搜词