【问题标题】:Use default settings.xml file instead of one in ~/.m2使用默认的 settings.xml 文件而不是 ~/.m2 中的一个
【发布时间】:2017-12-04 23:51:19
【问题描述】:

Maven 是否有可能忽略包含在 .m2 文件夹中的 settings.xml

我希望它使用默认存储库,但我的笔记本电脑已经为其他存储库配置了开发环境,我不想丢失这些设置。更重要的是,这些存储库优先于我的pom.xml 中的存储库,如果它们无法下载工件,则会失败。

有哪些选择?我应该选择其他settings.xml 文件还是可以选择不使用?

【问题讨论】:

  • pom 文件中的第一个存储库是一种不好的做法...此外,您的 settings.xml 是否包含听起来不像那样的存储库管理器的配置...

标签: maven settings


【解决方案1】:

您不必在.m2 文件夹中有settings.xml。如果没有,Maven 使用<Maven installation folder>/conf/settings.xml,默认情况下所有内容都会被注释掉。

另见Settings Reference, Quick Overview

settings.xml 文件可能存在两个位置:

  • Maven 安装:${maven.home}/conf/settings.xml
  • 用户安装:${user.home}/.m2/settings.xml

你可以使用custom settings files with the command line options:

-s,--设置
用户设置文件的备用路径

-gs, --global-settings
全局设置文件的备用路径

而且,顺便说一句,.m2 不是 Maven 家。这是user-specific configuration and local repository 的文件夹。我相应地更正了问题的标题。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-11-01
    • 2013-04-01
    • 2013-01-18
    • 2010-12-27
    • 1970-01-01
    • 1970-01-01
    • 2020-08-05
    相关资源
    最近更新 更多