记一次jar冲突的问题

问题

业务中需要在spark中链接redis作为服务缓存,spark程序中引入redis的jar包后上传spark集群运行是报java.lang.NoSuchMethodError: com.xxx.common.pool.ConnectionPool.startAsync()Lcom/google/common/util/concurrent/Service;根据报错信息发现是jar包冲突造成

解决方式

  1. 根据报错信息判断是com/google/common/util这个包造成的冲突,在idea的external中找到该包的maven坐标应该是com.google.guava:guava:18.0
  2. 然后在idea的Dependency Analyzer中搜索guava发现生效的包和redis包中的版本相同,所以冲突应该不是本地项目造成的
  3. 然后有将jar上传tce运行,发现没有问题。因此定位问题应该是本地项目的com.google.guava依赖和spark集群中的依赖冲突造成
  4. 通过maven的shade插件将com.google.guava重命名后解决jar包冲突问题
<plugin>
	<groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-shade-plugin</artifactId>
    <version>3.2.1</version>
    <executions>
    	<execution>
    		<phase>package</phase>
            <goals>
                <goal>shade</goal>
            </goals>
            <configuration>
            	<minimizeJar>false</minimizeJar>
                <createDependencyReducedPom>false</createDependencyReducedPom>
                <relocations>
                   <relocation>
                       <pattern>com.google.common</pattern>
                       <shadedPattern>shade.com.google.common</shadedPattern>
                   </relocation>
                </relocations>
                <filters>
                	<filter>
                        <artifact>*:*</artifact>
                        <excludes>
                            <exclude>META-INF/*.SF</exclude>
                            <exclude>META-INF/*.DSA</exclude>
                            <exclude>META-INF/*.RSA</exclude>
                        </excludes>
                    </filter>
                </filters>
            </configuration>
    	</execution>
    </executions>
</plugin>

相关推荐

  1. jar冲突问题

    2023-12-19 17:38:03       44 阅读
  2. golang交叉编译问题

    2023-12-19 17:38:03       13 阅读
  3. 【线上问题更新问题

    2023-12-19 17:38:03       13 阅读

最近更新

  1. TCP协议是安全的吗?

    2023-12-19 17:38:03       18 阅读
  2. 阿里云服务器执行yum,一直下载docker-ce-stable失败

    2023-12-19 17:38:03       19 阅读
  3. 【Python教程】压缩PDF文件大小

    2023-12-19 17:38:03       19 阅读
  4. 通过文章id递归查询所有评论(xml)

    2023-12-19 17:38:03       20 阅读

热门阅读

  1. PHP解决Safari浏览器下载文件文件名称乱码的问题

    2023-12-19 17:38:03       56 阅读
  2. Zabbix“专家坐诊”第220期问答汇总

    2023-12-19 17:38:03       34 阅读
  3. moment.js使用diff方法返回NaN

    2023-12-19 17:38:03       38 阅读
  4. 自定义折线图的颜色 Python

    2023-12-19 17:38:03       36 阅读
  5. MVC环境搭建

    2023-12-19 17:38:03       35 阅读
  6. 开源许可证保姆级入门手册

    2023-12-19 17:38:03       40 阅读