在 maven shade 插件中包含依赖项

Include dependency in maven shade plugin

我正在尝试创建一个使用 Apache 的 commons-lang3 的可部署 jar。但是我的 Hadoop 所在的 AWS 集群不包含这个库,所以我得到一个 classNotFoundException。我认为我需要手动添加该依赖项,但我在使用 maven 阴影插件时遇到问题(我被推荐使用它)我当前的 pom 文件如下所示:

    <dependency>
        <groupId>org.apache.pig</groupId>
        <artifactId>pig</artifactId>
        <version>0.12.0-cdh5.2.6</version>
    </dependency>

    <dependency>
        <groupId>org.apache.commons</groupId>
        <artifactId>commons-lang3</artifactId>
        <version>3.4</version>
    </dependency>
    <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-shade-plugin</artifactId>
            <version>2.4.3</version>
            <executions>
                <execution>
                    <phase>package</phase>
                    <goals>
                        <goal>shade</goal>
                    </goals>
                    <configuration>
                        <artifact>org.apache.commons:commons-lang3</artifact>
                                <includes>
                                    <include>org/apache/commons/commons-lang3/3.4/*</include>
                                </includes>
                        <minimizeJar>true</minimizeJar>
                    </configuration>
                </execution>
            </executions>

        </plugin>

我想要一个完全正常的 jar,并在其中嵌入了 commons-lang3 库。是不是我做错了什么?

要包含列入白名单的 jar,您需要执行以下操作:

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-shade-plugin</artifactId>
            <version>2.4.3</version>
            <executions>
                <execution>
                    <phase>package</phase>
                    <goals>
                        <goal>shade</goal>
                    </goals>
                    <configuration>
                        <artifactSet>
                            <includes>
                                <include>org.apache.commons:commons-lang3</include>
                            </includes>
                        </artifactSet>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>