maven系列四 —— maven配置文件详解(setting.xml 和 pom.xml)

先来说说settings.xml,settings.xml对于maven来说相当于全局性的配置,用于所有的项目。

settings.xml存在于两个地方:

 

1.安装的地方:$M2_HOME/conf/settings.xml

 

2.用户的目录:${user.home}/.m2/settings.xml

 

前者又被叫做全局配置,后者被称为用户配置。如果两者都存在,它们的内容将被合并,并且用户范围的settings.xml优先。

 

如果你偶尔需要创建用户范围的settings,你可以简单的copy Maven安装路径下的settings到目录${user.home}/.m2。Maven默认的settings.xml是一个包含了注释和例子的模板,你可以快速的修改它来达到你的要求。

 

 

<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/>
    <interactiveMode/>
    <usePluginRegistry/>
    <offline/>
    <pluginGroups/>
    <servers/>
    <mirrors/>
    <proxies/>
    <profiles/>
    <activeProfiles/>
</settings>

 

<localRepository>F:\a安装程序\maven\sonatype-work\nexus\storage\central</localRepository>

localRepository:这个值是构建系统的本地仓库的路径。默认的值是${user.home}/.m2/repository.如果一个系统想让所有登陆的用户都用同一个本地仓库的话,这个值是极其有用的。

 

<offline>false</offline>

offline:如果构建系统要在离线模式下工作,设置为true,默认为false。如果构建服务器因为网络故障或者安全问题不能与远程仓库相连,那么这个设置是非常有用的。

 

 

 

 

 

猜你喜欢

转载自hbiao68.iteye.com/blog/2104524