settings.xml 是 Maven 的配置文件,用于配置Maven的一些基本选项,如本地仓库位置、远程仓库、认证信息等。它位于 ${maven.home}/conf/settings.xml 。
settings.xml 中常用的配置项有:
- :配置本地仓库路径,默认为${user.home}/.m2/repository。
- :配置是否交互式确认,true表示确认,false表示非确认。默认为true。
- :配置是否使用插件注册表,true表示使用,false表示不使用。默认为false。
- :配置是否离线模式构建,true表示离线模式,false表示联网模式。默认为false。
- :配置插件组织的列表。
- :配置代理信息。
- :配置服务端的认证信息。
- :配置镜像信息。
- :配置环境信息。
来看一个简单示例:
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
http://maven.apache.org/xsd/settings-1.0.0.xsd">
<localRepository>D:/maven/repository</localRepository>
<interactiveMode>false</interactiveMode>
<usePluginRegistry>true</usePluginRegistry>
<offline>false</offline>
<servers>
<server>
<id>server1</id>
<username>my_login</username>
<password>my_password</password>
</server>
</servers>
</settings>
在该示例中,我们配置了:
- 本地仓库路径为D:/maven/repository。
- 非交互式确认模式。
- 使用插件注册表。
- 联网模式。
- server1服务的登录认证信息。