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>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值