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

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

java 复制代码
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来打包并隔离依赖,就是重命名包名

XML 复制代码
<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包

XML 复制代码
<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包

XML 复制代码
<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>
相关推荐
eastyuxiao1 小时前
第二章 数字孪生核心技术体系
大数据·人工智能·数字孪生
andy_haiying1 小时前
深圳网站建设公司推荐哪家好?2026年5月官网制作服务商综合评测
大数据·人工智能
zxrhhm2 小时前
PostgreSQL 大规模随机数据生成完整指南
大数据·数据库·postgresql
飞飞传输2 小时前
数字化科研提速关键 构建安全可控一体化跨网数据传输体系
大数据·运维·安全
Elastic 中国社区官方博客2 小时前
Elastic 的 AI agent skills
大数据·人工智能·elasticsearch·搜索引擎·ai·全文检索
陕西字符2 小时前
2026 西安小微企业地图与 AI 问答排名优化:专业技术指南与落地方案
大数据·人工智能
MetrixAeroCore3 小时前
车规级国际物联卡是什么?车载物联网硬件选型与行业标准解析
大数据·物联网
189228048613 小时前
H27QCG8T2ELR-BCF海力士H27QCG8UDBIR-BCB
大数据·服务器·人工智能·科技·缓存
财经资讯数据_灵砚智能3 小时前
基于全球经济类多源新闻的NLP情感分析与数据可视化(夜间-次晨)2026年5月10日
大数据·人工智能·python·信息可视化·自然语言处理
lizhihai_993 小时前
股市学习心得-智能体顶层设计文件收益供应链
大数据·人工智能·学习