maven配置之settings.xml详解

文件存放位置

全局配置: ${M2_HOME}/conf/settings.xml

用户配置: ${user.home}/.m2/settings.xml

note:用户配置优先于全局配置。${user.home} 和和所有其他系统属性只能在3.0+版本上使用。请注意windows和Linux使用变量的区别。

 

settings.xml详解

声明规范

xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">

localRepository

 
 <localRepository>usr/local/mavenlocalRepository>

interactiveMode

 
 <interactiveMode>trueinteractiveMode>

usePluginRegistry


 <usePluginRegistry>falseusePluginRegistry>

offline

 
 <offline>falseoffline>

pluginGroups

复制代码

 <pluginGroups>
  
  <pluginGroup>org.codehaus.mojopluginGroup>
 pluginGroups>
复制代码

proxies

复制代码

 <proxies>
  
  <proxy>
   
   <id>myproxyid>
   
   <active>trueactive>
   
   <protocol>httpprotocol>
   
   <host>proxy.somewhere.comhost>
   
   <port>8080port>
   
   <username>proxyuserusername>
   
   <password>somepasswordpassword>
   
   <nonProxyHosts>*.google.com|ibiblio.orgnonProxyHosts>
  proxy>
 proxies>
复制代码

servers

复制代码

 <servers>
  
  <server>
   
   <id>server001id>
   
   <username>my_loginusername>
   
   <password>my_passwordpassword>
   
   <privateKey>${usr.home}/.ssh/id_dsaprivateKey>
   
   <passphrase>some_passphrasepassphrase>
   
   <filePermissions>664filePermissions>
   
   <directoryPermissions>775directoryPermissions>
  server>
 servers>
复制代码

mirrors

复制代码

 <mirrors>
  
  <mirror>
   
   <id>planetmirror.comid>
   
   <name>PlanetMirror Australianame>
   
   <url>http://downloads.planetmirror.com/pub/maven2url>
   
   <mirrorOf>centralmirrorOf>
  mirror>
 mirrors>
复制代码

profiles

复制代码
 
 <profiles>
  
  <profile>
   
   <id>testid>
复制代码

Activation

复制代码

   <activation>
    
    <activeByDefault>falseactiveByDefault>
    
    <jdk>1.5jdk>
    
    <os>
     
     <name>Windows XPname>
     
     <family>Windowsfamily>
     
     <arch>x86arch>
     
     <version>5.1.2600version>
    os>
    
    <property>
     
     <name>mavenVersionname>
     
     <value>2.0.3value>
    property>
    
    <file>
     
     <exists>${basedir}/file2.propertiesexists>
     
     <missing>${basedir}/file1.propertiesmissing>
    file>
   activation>
复制代码

Properties

复制代码
 
   <properties>
   <user.install>${user.home}/our-projectuser.install>
   properties>
note:如果该profile被激活,则可以再POM中使用${user.install}。
复制代码

Repositories

复制代码
  
   <repositories>
    
    <repository>
     
     <id>codehausSnapshotsid>
     
     <name>Codehaus Snapshotsname>
     
     <releases>
      
      <enabled>falseenabled>
      
      <updatePolicy>alwaysupdatePolicy>
      
      <checksumPolicy>warnchecksumPolicy>
     releases>
     
     <snapshots>
      <enabled/><updatePolicy/><checksumPolicy/>
     snapshots>
     
     <url>http://snapshots.maven.codehaus.org/maven2url>
     
     <layout>defaultlayout>
    repository>
   repositories>
   
   <pluginRepositories>
    
          <pluginRepository>           
     <releases>      
      <enabled/><updatePolicy/><checksumPolicy/>
     releases>
     <snapshots>
      <enabled/><updatePolicy/><checksumPolicy/>
     snapshots>
     <id/><name/><url/><layout/>
          pluginRepository>
        pluginRepositories>
  profile>
 profiles>
复制代码

activeProfiles

复制代码

   <activeProfiles>
    
    <activeProfile>env-testactiveProfile>
   activeProfiles>
settings>

你可能感兴趣的:(maven)