Maven的settings.xml文件结构详解

来源:互联网 发布:directx9修复软件64位 编辑:程序博客网 时间:2024/05/21 17:48

安装Maven后(可以只是解压缩下载的Maven发布包),在Maven安装目录下的conf/目录下有一个settings.xml文件。该文件事实上只是一个空模板,其中没有任何有效的设置。打开该文件,可以看到其引用的XML Schema如下:

http://maven.apache.org/xsd/settings-1.1.0.xsd


该文件的结构如下:

    <?xml version="1.0" encoding="UTF-8"?>    <settings xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.1.0 http://maven.apache.org/xsd/settings-1.1.0.xsd" xmlns="http://maven.apache.org/SETTINGS/1.1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">      <localRepository/>      <interactiveMode/>      <usePluginRegistry/>      <offline/>      <servers/>      <mirrors/>      <proxies/>      <profiles/>      <activeProfiles/>      <pluginGroups/>    </settings>
说明:

1.localRepository,给出本地库的路径,默认值为${user.home}/.m2/repository。该路径在build服务器上非常重要,项目构建过程中可以直接引用本地库中的通用类库。

2. interactiveMode,Maven执行过程中是否需要接受用户输入,默认值为true。

3. usePluginRegistry,是否使用plugin-registry.xml文件管理Maven插件的版本,默认为false。该文件为用户提供了选择,即使用指定版本的Maven插件,而非最新版本的Maven插件。该文件是从Maven 2开始出现的,但是事实上更常用的是在POM中配置Maven插件的版本等参数,所以usePluginRegistry参数往往为false。另外,与settings.xml文件类似,plugin-registry.xml文件也有全局和用户之分。

4. offline,是否支持离线构建系统,默认值为false。如果build服务器由于网络或者安全等原因不能连接远程库,则该参数设置为true。

5. pluginGroups,给出Maven插件所在的groupId,一个可能的groupId使用一个<pluginGroup>给出。该参数只是为了简化执行Maven时的参数,如为了执行如下命令:

mvn org.mortbay.jetty:jetty-maven-plugin:run

如果在settings.xml文件中配置了如下<pluginGroup>:

  <pluginGroups>    <pluginGroup>org.mortbay.jetty</pluginGroup>  </pluginGroups>

则可以直接执行如下命令:

mvn jetty:run

6. servers,给出用以下载或部署类库的服务器信息,详见后续文章。

7. mirrors,给出指定类库的镜像服务器信息,详见后续文章。

8. proxies,给出代理服务器信息,详见后续文章。

9. profiles,给出可用的profile,这里的profile类似于POM中的profile,但是只包含activationrepositoriespluginRepositoriesproperties等与project无关的信息,详见后续文章。

10. activeProfiles,默认采用的profile,可以有多个profile。


1 0
原创粉丝点击