如何获取pom.xml中提到的所有指定jar和传递依赖的jar?

How to get all the specified jars mentioned in the pom.xml and transitively dependent jars?

我只有 POM 文件,我需要使用它编写一个脚本来自动下载所有依赖文件并输出到自定义提到的路径。

我只是想在命令行中使用 mvn 命令来实现上述目标。

听起来你在找 mvn dependency:copy-dependencies:

dependency:copy-dependencies takes the list of project direct dependencies and optionally transitive dependencies and copies them to a specified location, stripping the version if desired. This goal can also be run from the command line.

从项目根目录,在命令行上调用

mvn dependency:copy-dependencies -DoutputDirectory=...

会将您的所有项目直接和传递依赖项复制到指定的 output directory。如果这些依赖项不在您的本地 Maven 存储库中,它们将从 Maven Central(或从自定义存储库)下载。