maven的setting.xml配置文件详解

文章目录

  • 一、Maven的重要配置文件有两个:settings.xml、pom.xml
  • 二、Maven的settings.xml为什么这么重要?

一、Maven的重要配置文件有两个:settings.xml、pom.xml

maven的pom.xml文件详解参考另一篇博文:maven的pom.xml文件详解

二、Maven的settings.xml为什么这么重要?

直接修改安装包下setting.xml文件,就能在机器上全局地定制 Maven 的行为。一般情况下,我们更偏向于复制该文件至 ~/.m2/ 目录下(~表示用户目录),然后修改该文件,在用户范围定制 Maven 的行为。Maven运行时,先找用户目录.m2文件夹的settings.xml,没有的话去安装包里面找全局的settings.xml。

实际应用中,经常使用的是有限几个节点,其他节点使用默认值足够应对大部分的应用场景。详细配置如下:

     
<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>usr/local/mavenlocalRepository> 
        
      
    <interactiveMode>trueinteractiveMode>  
        
      
      
      
    <usePluginRegistry>falseusePluginRegistry>  
        
      
      
    <offline>falseoffline>  
        
      
      
      
      
    <pluginGroups>  
            
          
        <pluginGroup>org.codehaus.mojopluginGroup>  
           
    pluginGroups>  
        
      
    <proxies>  
            
          
        <proxy>  
                
              
            <id>myproxyid>  
                
              
            <active>trueactive>  
                
              
            <protocol>http://…protocol>  
                
              
            <host>proxy.somewhere.comhost>  
                
              
            <port>8080port>  
                
               
            <username>proxyuserusername>  
                
              
            <password>somepasswordpassword>  
                
              
            <nonProxyHosts>*.google.com|ibiblio.orgnonProxyHosts>  
                
        proxy>  
           
    proxies>  
        
      
    <servers>  
            
          
        <server>  
                
              
            <id>server001id>  
                
              
            <username>my_loginusername>  
                
              
            <password>my_passwordpassword>  
                
              
              
            <privateKey>${usr.home}/.ssh/id_dsaprivateKey>  
                
              
            <passphrase>some_passphrasepassphrase>  
                
              
              
            <filePermissions>664filePermissions>  
                
              
            <directoryPermissions>775directoryPermissions>  
                
              
            <configuration>configuration>  
                
        server>  
           
    servers>  
        
      
    <mirrors>  
            
          
        <mirror>  
                
              
            <id>planetmirror.comid>  
                
              
            <name>PlanetMirror Australianame>  
                
              
            <url>http://downloads.planetmirror.com/pub/maven2url>  
                
              
              
            <mirrorOf>centralmirrorOf>  
                
        mirror>  
           
    mirrors>  
        
      
      
      
      
    <profiles>  
            
          
        <profile>  
                
              
            <id>testid>  
                
              
              
              
              
            <activation>  
                    
                  
                <activeByDefault>falseactiveByDefault>  
                    
                  
                <jdk>1.7jdk>  
                    
                  
                <os>  
                        
                      
                    <name>Windows XPname>  
                        
                      
                    <family>Windowsfamily>  
                        
                      
                    <arch>x86arch>  
                        
                      
                    <version>5.1.2600version>  
                          
                os>  
                    
                  
                  
                <property>  
                        
                      
                    <name>mavenVersionname>  
                        
                      
                    <value>2.0.3value>  
                          
                property>  
                    
                  
                  
                <file>  
                        
                      
                    <exists>/usr/local/hudson/hudson-home/jobs/maven-guide-zh-to-production/workspace/exists>  
                        
                      
                    <missing>/usr/local/hudson/hudson-home/jobs/maven-guide-zh-to-production/workspace/missing>  
                          
                file>  
                     
            activation>  
                
               
              
               
              
              
              
              
              
            <properties>  
              
                  
                <user.install>usr/local/winner/jobs/maven-guideuser.install>  
                     
            properties>  
                
              
            <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>  
                
              
              
              
              
            <activeProfiles>  
                      
                <activeProfile>env-testactiveProfile>  
                     
            activeProfiles>  
                
        profile>  
           
    profiles>  
        
settings>  

你可能感兴趣的:(《git,maven工具日常》系列,maven)