如果我不能使用默认的 Maven 本地存储库设置,如何指定 Maven 本地存储库?

How to specify Maven local repository if I cannot use default Maven local repository settings?

我们对 $HOME 的大小有限制,因此我不能使用默认设置 ~/.m2/ 我们在每个作业配置中使用 "use private maven repository" 选项。如果作业 2 依赖于作业 1 生成的工件,该怎么办。

如果你直接使用 maven(也许通过命令行)而不是在你的 maven 的 conf 目录中创建一个 settings.xml。此 settings.xml 应如下所示:

<settings>
    <localRepository>C:\Repository</localRepository>
</settings>

如果您使用的是 Eclipse,那么将 settings.xml 放在任何您想要的位置,然后在 Eclipse 中转到 Window -> Preferences -> Maven -> User Settings 并使用您的 settings.xml 的路径设置 User Settings .

命令行最简单的解决方案是通过命令行给它:

mvn -Dmaven.repo.local=WhereEverYouLikeToHaveYourRepo