如何使用maven命令行来确定maven正在拾取哪个settings.xml文件?
当前回答
这是Maven的配置文件。它可以在两个级别上指定:
User Level. This settings.xml file provides configuration for a single user, and is normally provided in ${user.home}/.m2/settings.xml. NOTE: This location can be overridden with the CLI option: -s /path/to/user/settings.xml Global Level. This settings.xml file provides configuration for all Maven users on a machine (assuming they're all using the same Maven installation). It's normally provided in ${maven.home}/conf/settings.xml. NOTE: This location can be overridden with the CLI option: -gs /path/to/global/settings.xml
其他回答
这是Maven的配置文件。它可以在两个级别上指定:
User Level. This settings.xml file provides configuration for a single user, and is normally provided in ${user.home}/.m2/settings.xml. NOTE: This location can be overridden with the CLI option: -s /path/to/user/settings.xml Global Level. This settings.xml file provides configuration for all Maven users on a machine (assuming they're all using the same Maven installation). It's normally provided in ${maven.home}/conf/settings.xml. NOTE: This location can be overridden with the CLI option: -gs /path/to/global/settings.xml
您可以使用maven帮助插件来告诉您用户和全局设置文件的内容。
mvn help:effective-settings
将要求maven吐出组合的全局和用户设置。
您对cletus(正确)回答的评论暗示涉及多个Maven设置文件。
Maven总是使用一个或两个设置文件。(${M2_HOME}/conf/settings.xml)中定义的全局设置始终是必需的。用户设置文件(定义在${user.home}/.m2/settings.xml中)是可选的。在用户设置中定义的任何设置优先于相应的全局设置。
你可以从命令行覆盖全局和用户设置的位置,下面的例子将全局设置设置为c:\global\settings.xml,用户设置为c:\user\settings.xml:
mvn install --settings c:\user\settings.xml
--global-settings c:\global\settings.xml
目前还没有属性或方法来确定Maven使用了哪些用户和全局设置文件。要访问这些值,您必须修改MavenCli和/或DefaultMavenSettingsBuilder以将文件位置注入解析的Settings对象。
如果您像我一样在调试和浪费时间,这将提供包括密码在内的详细信息。: P
mvn help:effective-settings -DshowPasswords=true
全局变量的M2_HOME环境变量。参见设置参考:
The settings element in the settings.xml file contains elements used to define values which configure Maven execution in various ways, like the pom.xml, but should not be bundled to any specific project, or distributed to an audience. These include values such as the local repository location, alternate remote repository servers, and authentication information. There are two locations where a settings.xml file may live: The Maven install: $M2_HOME/conf/settings.xml A user's install: ${user.home}/.m2/settings.xml