您可以使用maven-dependency-plugin
(看here),如下圖所示,這個插件會提供很多的選擇,包括罐其中的artifactId(即<includeArtifactIds>
)或的groupId(<includeGroupIds>
),等等
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>prepare-package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/
classes/lib</outputDirectory>
<overWriteReleases>false</overWriteReleases>
<overWriteSnapshots>false</overWriteSnapshots>
<overWriteIfNewer>true</overWriteIfNewer>
<includeArtifactIds>YOUR_THIRDPARTY_JAR_NAME</includeArtifactIds>
</configuration>
</execution>
</executions>
</plugin>
所以,上面的代碼將添加到YOUR_THIRDPARTY_JAR_NAME.jar
最終.jar
文件的文件夾lib
。