guava&hive-exec冲突解决

缘由:

解决:

maven-shade插件解决,以下为plugin配置:apache

<plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-shade-plugin</artifactId>
                <version>3.0.0</version>
                <configuration>
                    <keepDependenciesWithProvidedScope>false</keepDependenciesWithProvidedScope>
                    <promoteTransitiveDependencies>false</promoteTransitiveDependencies>
                    <createDependencyReducedPom>true</createDependencyReducedPom>
                    <minimizeJar>false</minimizeJar>
                    <createSourcesJar>false</createSourcesJar>
                </configuration>

                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>shade</goal>
                        </goals>

                        <configuration>
                            <artifactSet>
                                <includes>
                                    <include>org.apache.hive:hive-exec</include>
                                </includes>
                            </artifactSet>

                            <filters>
                                <filter>
                                    <artifact>*:*</artifact>
                                    <excludes>
                                        <exclude>META-INF/*.SF</exclude>
                                        <exclude>META-INF/*.DSA</exclude>
                                        <exclude>META-INF/*.RSA</exclude>
                                    </excludes>
                                </filter>
                            </filters>

                            <relocations>
                                <relocation>
                                    <pattern>com.google.guava</pattern>
                                    <shadedPattern>com.medata.google.guava</shadedPattern>
                                </relocation>
                                <relocation>
                                    <pattern>com.google.common</pattern>
                                    <shadedPattern>com.medata.google.common</shadedPattern>
                                </relocation>
                            </relocations>

                            <transformers>
                                <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer" />
                            </transformers>

                        </configuration>
                    </execution>
                </executions>
复制代码

遇到的问题:

  1. 因为本项目要求hive shade包不能引出去,全部在多个module中分别引用;因为单独引用hive-shade包会致使工程内引用hive-exec的包的地方会找不到引用,此时须要作两个操做:
  • (1)单独install hive-shade包
  • (2)在module中在单独引用hive-exec而且修改scope为provide (表示此依赖参与编译、测试,在打包时exculde)

maven scope详解bash

  1. 引用以后须要注意排掉log4j相关包,而且排除掉hive-exec的包,由于通过mvn-shade插件以后会将hive-exec包打成一个新的shade包,和hive-exec包无关了须要直接排掉;

相关文章
相关标签/搜索