- 创建pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.sample</groupId>
<artifactId>download-jar</artifactId>
<version>1.0</version>
<packaging>pom</packaging>
<dependencies>
<!-- 要下载的项目 -->
<dependency>
<groupId>org.sample</groupId>
<artifactId>app</artifactId>
<version>1.0</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<configuration>
<!-- 不要下载间接依赖的包 -->
<excludeTransitive>true</excludeTransitive>
<!-- 复制的包去掉版本信息 -->
<stripVersion>true</stripVersion>
<!-- 复制到当前路径下的target文件夹里 -->
<outputDirectory>./target</outputDirectory>
</configuration>
</plugin>
</plugins>
</build>
</project>
- 执行命令
mvn dependency:copy-dependencies
注:如果excludeTransitive没有配置为true,则会将所有间接依赖的包都下载下来