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>
相关推荐
大大大大晴天8 小时前
从 Prompt 到 Tool Calling:AI Agent 如何稳定连接程序世界
大数据·agent
key_3_feng8 小时前
反馈闭环:Agent 自我进化的真正引擎
大数据·agent
EnCi Zheng9 小时前
Agent 如何进行工具调用:从一次 Function Calling 到生产级工具编排的完整链路
大数据·人工智能·agent·ai编程·工具调用
GlobalInfo9 小时前
重磅发布 | 2026年船体清洁机器人行业研究报告:市场规模、发展前景与十五五战略地图
大数据·人工智能·机器人
海宇服务9 小时前
零信任架构实战:基于海宇全能小微企业报告构建自动化园区商户免押租赁资信核验网关
大数据·人工智能·架构·自动化
热文新讯10 小时前
迎进博·话疗愈:2026酒店“疗愈睡眠”闭门研讨会在沪举行
大数据·人工智能·物联网
NailiConveyor13 小时前
柔性物流方案如何适配工厂升级?自动化输送流水线定制要点
大数据·运维·自动化·制造·业界资讯
梦影_13 小时前
MySQL进阶教程(五)—— SQL调优(下)
android·大数据·数据库·后端·sql·mysql·database
没落之王14 小时前
三易五行看宋朝的三界确立
大数据·人工智能·算法
乌恩大侠16 小时前
「AI-RAN」Aerial,使用ORAN C1模式
人工智能·5g·spark·o-ru·ai-ran