业务中需要在spark中链接redis作为服务缓存,spark程序中引入redis的jar包后上传spark集群运行是报java.lang.NoSuchMethodError: com.xxx.common.pool.ConnectionPool.startAsync()Lcom/google/common/util/concurrent/Service;
根据报错信息发现是jar包冲突造成
com/google/common/util
这个包造成的冲突,在idea的external中找到该包的maven坐标应该是com.google.guava:guava:18.0
com.google.guava
依赖和spark集群中的依赖冲突造成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>