我近期已经从新浪离职,重新加入了阿里巴巴集团,目前在阿里云EMR团队中工作,工作的主要内容还是围绕着大数据底层架构展开。
在我们像集群中提交任务的时候,常常因为app的jar包与Hadoop CLASSPATH中jar包冲突导致了No such method错误等等。
为了解决这一问,采用Maven-shade-plugin,这个插件的主要作用是将打包过程中内部的jar包重新命名为新的名称,防止由于引用不同版本导致的问题,例如:
<project> ... <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-shade-plugin</artifactId> <version>3.0.0</version> <executions> <execution> <phase>package</phase> <goals> <goal>shade</goal> </goals> <configuration> <relocations> <relocation> <pattern>org.codehaus.plexus.util</pattern> <shadedPattern>org.shaded.plexus.util</shadedPattern> <excludes> <exclude>org.codehaus.plexus.util.xml.Xpp3Dom</exclude> <exclude>org.codehaus.plexus.util.xml.pull.*</exclude> </excludes> </relocation> </relocations> </configuration> </execution> </executions> </plugin> </plugins> </build> ... </project> |