使用Maven Shade插件创建具有Dependent jar的依赖项文件夹

我正在使用maven shade插件创建一个胖罐,其中包括一些充气城堡罐.但是由于Bouncy Castle的未签名版本,这就产生了问题.

java.lang.SecurityException:JCE无法验证提供程序BC

现在解决方案之一是拥有依赖项的外部文件夹,并在fat jar的manifest文件中定义此类路径.

例如:

<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>
                                <excludes>
                                    <exclude>org.bouncycastle:*:*:*</exclude>
                                </excludes>
                            </artifactSet>
                        <finalName>Relay-S3-Monitor-jar-with-dependencies</finalName>
                        <filters>
                            <filter>
                                <artifact>*:*</artifact>
                                <excludes>
                                    <exclude>META-INF/*.SF</exclude>
                                    <exclude>META-INF/*.DSA</exclude>
                                    <exclude>META-INF/*.RSA</exclude>
                                </excludes>
                            </filter>
                        </filters>
                        <transformers>
                            <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                                <mainClass>at.seresunit.lecturemanager_connector.App</mainClass>
                            </transformer>
                            <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
                                <resource>META-INF/spring.handlers</resource>
                            </transformer>
                            <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
                                <resource>META-INF/spring.schemas</resource>
                            </transformer>
                            <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                                 <manifestEntries>
                                    <Main-Class>com.pb.relay.s3.CamelBoot</Main-Class>
                                    <Class-Path>. bouncycastle_libs/bcpg-jdk15on-1.55.jar bouncycastle_libs/bcprov-jdk15on-1.55.jar bouncycastle_libs/bcprov-jdk16-1.45.jar</Class-Path>
                                </manifestEntries>
                            </transformer>
                        </transformers>
                    </configuration>
                </execution>
            </executions>
        </plugin

现在我需要的是:在同一个pom.xml中,我需要插入一个创建依赖文件夹的部分(插件)(只有弹性城堡jar)

最佳答案 使用依赖项插件,您可以调用dependency:copy将依赖项复制到文件夹

https://maven.apache.org/plugins/maven-dependency-plugin/copy-mojo.html

点赞