简体   繁体   中英

How can I tell maven to use specific settings.xml on project bases?

So my project comes with settings.xml together with its pom.xml .

Is there any way in pom.xml to specify to use the settings.xml in the same folder?

It seems that Maven does not allow what you are trying to do, and moreover specifically advised against it. The following excerpt is taken from the official documentation which is here :

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

The former settings.xml are also called global settings, the latter settings.xml are referred to as user settings. If both files exists, their contents gets merged, with the user-specific settings.xml being dominant.

If someone is still interested, at least with Maven 3.6.3 you can specify the path to the user settings file as an argument with

-s /path/to/user/settings.xml

Likewise, the path to the global settings is specified with

-gs /path/to/global/settings.xml

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM