<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    qqjianyue代碼工

    砌java代碼
    posts - 62, comments - 9, trackbacks - 0, articles - 10
      BlogJava :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理

    maven2 setting文件詳解

    Posted on 2008-09-08 11:01 Qzi 閱讀(13237) 評論(0)  編輯  收藏 所屬分類: appfuse2 and maven2

    以下完全照搬官網:http://maven.apache.org/settings.html  只是加上一點自己的理解而已
    可以具有兩個setting文件:
    1.$M2_HOME/conf/settring.xml安裝Maven就有的系統setting(各個用戶有效的全局的)
    2.${user.home}/.m2/settring.xml用戶自己加在Repository里的setting文件(用戶級的)

    元素總覽:

    <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/>
    <interactiveMode/>
    <usePluginRegistry/>
    <offline/>
    <pluginGroups/>
    <servers/>
    <mirrors/>
    <proxies/>
    <profiles/>
    <activeProfiles/>
    </settings>
    
  • localRepository:配置本地的Repository路徑,可以是絕對路徑,通常寫的是${user.home}/.m2/repository
  • interactiveMode:是否希望maven與用戶輸入進行交互,true的話,maven就有可能與用戶交互,默認是true
  • usePluginRegistry:如果需要使用${user.home}/.m2/plugin-registry.xml來控制plugin的版本的話,就是true,現在默認為false,因為maven2.0,不建議依賴這個文件
  • offline: 是否為離線運行狀態,默認為false,對于不能夠使用遠程Repository的,使用true
  • pluginGroups: 包含一組pluginGroup元素,如果在命令行上沒有聲明使用某個插件,又要用到這個插件,就在這里的pluginGroup里聲明。這個列表默認包括org.maven.plugins
  • Servers:Repositories的詳細定義在pom.xml的distributionManagement中,但是
  •     <server>
          <id>server001</id>
          <username>my_login</username>
          <password>my_password</password>
          <privateKey>${user.home}/.ssh/id_dsa</privateKey>
          <passphrase>some_passphrase</passphrase>
          <filePermissions>664</filePermissions>
          <directoryPermissions>775</directoryPermissions>
          <configuration></configuration>
        </server>

    這些是在這里定義的。
    id:與distributionManagement中的repository中的元素id對應,用于表示一個server
    username,password:如果server需要驗證的話,這一對元素就是用于驗證的
    privateKey, passphrase:也是用于服務器驗證的,前者指定私鑰privateKey(默認${user.home}/.ssh/id_dsa),后者指定口號passphrase
    filePermissions, directoryPermissions:使用linux中的三位數字形式標示文件與路徑的權限,例如664,775等。
    注意:如果使用私鑰登錄服務器的話,那么password就省略,否則,私鑰會被忽略。
    configuration:官網也沒有解釋。

  • Mirrors
  •     <mirror>
          <id>planetmirror.com</id>
          <name>PlanetMirror Australia</name>
          <url>http://downloads.planetmirror.com/pub/maven2</url>
          <mirrorOf>central</mirrorOf>
        </mirror>
    id,name:server鏡像的唯一標識與可讀性強的名稱(id才是唯一的)

    url:mirror的地址
    mirrorOf:指定這個鏡像代表的server的id,那么以后工程引用這個server的時候將不會使用server而是變成使用mirror的地址

    In 2.0.9+, an enhanced syntax is supported:

    • * matches all repo ids.
    • external:* matches all repos except those using localhost or file based repositories. This is used in conjunction with a repository manager when you want to exclude redirecting repositories that are defined for Integration Testing.
    • multiple repos may be specified using , as the delimiter
    • ! may be used in conjunction with one of the above wildcards to exclude a repo id.

    The order is not important from left to right as the wildcards defer to further processing and explicit includes or excludes stop the processing. Additionally, the mirror list will now be ordered using a LinkedHashMap instead of HashMap such that the user may influence match order by changing the order of the definitions in the settings.xml

    Examples:

    • * = everything
    • external:* = everything not on the localhost and not file based.
    • repo,repo1 = repo or repo1
    • *,!repo1 = everything except repo1

  • Proxies
  •     <proxy>
          <id>myproxy</id>
          <active>true</active>
          <protocol>http</protocol>
          <host>proxy.somewhere.com</host>
          <port>8080</port>
          <username>proxyuser</username>
          <password>somepassword</password>
          <nonProxyHosts>*.google.com|ibiblio.org</nonProxyHosts>
        </proxy>
    id:表示不同的proxy
    active:當有多個proxy的時候,只有active為true的時候才是有效的
    protocol,host,port:協議,主機,端口
    username,password:如果需要的話就加上
    nonProxyHosts:排除不用代理的站點,使用“|”或者“,”符號分開不同站點,可以使用通配符“*”

  • profiles
  • activation, repositories, pluginRepositories and properties elements
        activation指定激活這個profile的條件。其他激活的方法:(1)setting.xml可以通過activeProfile元素指定profile的id,來明確地激活這個profile。(2)在命令行上加上-P profile的id,也可以激活這個profile,其中可以通過“,”分開幾個profile的id來指定多個。
        repositories包含的repository指定依賴,它之前的activation如果符合激活條件的話就開啟這個依賴
        pluginRepositories和properties也一樣,如果activation符合激活條件,則它們將被激活
    例子1:如果使用jdk-1.4的話,jdk的依賴將會被激活

        <profile>
          <id>jdk-1.4</id>

          <activation>
            <jdk>1.4</jdk>
          </activation>

          <repositories>
            <repository>
       <id>jdk14</id>
       <name>Repository for JDK 1.4 builds</name>
       <url>http://www.myhost.com/maven/jdk14</url>
       <layout>default</layout>
       <snapshotPolicy>always</snapshotPolicy>
     </repository>
          </repositories>
        </profile>

    例子2:如果target-env的屬性值為dev的時候,就激活tomcatPath的屬性,其他地方肯定會有元素引用這個屬性,例如后面引用

        <profile>
          <id>env-dev</id>

          <activation>
            <property>
       <name>target-env</name>
       <value>dev</value>
     </property>
          </activation>

          <properties>
            <tomcatPath>/path/to/tomcat/instance</tomcatPath>
          </properties>
        </profile>
        -->
      </profiles>

    引用tomcatPath
         | <plugin>
         |   <groupId>org.myco.myplugins</groupId>
         |   <artifactId>myplugin</artifactId>
         |  
         |   <configuration>
         |     <tomcatLocation>${tomcatPath}</tomcatLocation>
         |   </configuration>
         | </plugin>


  • Properties
  • 屬性的引用可以通過${},其中:
    1)env.***是引用命令行comandline參數既環境變量等參數的值,例如%{env.PATH}引用環境變量path的值
    2)project.***引用pom文件中project的元素值,例如pom中有個<project><version>1.0</version></project>,那么可以%{project.version}
    3)setting.***引用setting文件中的元素值,例如:<settings><offline>false</offline></settings> is accessible via ${settings.offline}
    4)java.***,java System Properties:在java語言中可以通過java.lang.System.getProperties() 獲得的值都可以通過此來獲得,例如:${java.home}
    5)***是在<properties/>中定義了的可以直接引用的屬性,方法%{someVar}。

  • Repositories
  •      <repositories>
            <repository>
              <id>codehausSnapshots</id>
              <name>Codehaus Snapshots</name>
              <releases>
                <enabled>false</enabled>
                <updatePolicy>always</updatePolicy>
                <checksumPolicy>warn</checksumPolicy>
              </releases>
              <snapshots>
                <enabled>true</enabled>
                <updatePolicy>never</updatePolicy>
                <checksumPolicy>fail</checksumPolicy>
              </snapshots>
              <url>http://snapshots.maven.codehaus.org/maven2</url>
              <layout>default</layout>
            </repository>
          </repositories>
    1)releases, snapshots:(理解不了,原文照搬)These are the policies for each type of artifact, Release or snapshot. With these two sets, a POM has the power to alter the policies for each type independent of the other within a single repository. For example, one may decide to enable only snapshot downloads, possibly for development purposes.
    2)enabled:true或者false來指明這個repository哪個類型被開啟
    3)updatePolicy:升級策略。The choices are: always, daily (default), interval:X (where X is an integer in minutes) or never
    4)checksumPolicy:When Maven deploys files to the repository, it also deploys corresponding checksum files. options are to ignore, fail, or warn on missing or incorrect checksums
    5)layout:In the above description of repositories, it was mentioned that they all follow a common layout. This is mostly correct. Maven 2 has a default layout for its repositories; however, Maven 1.x had a different layout. Use this element to specify which if it is default or legacy.

  • Plugin Repositories
  • 結構如同Repositories,但是可以這樣理解,repositories用于工程運行之前的,plugin Repositories用于運行。例如tomcat jetty等都是plugins,而jdk,jar等運行之前的工程編譯時候就已經用到了

  • activeProfiles如上所說,可以指定一定激活的profile
  • activeProfiles

    只有注冊用戶登錄后才能發表評論。


    網站導航:
     
    主站蜘蛛池模板: a拍拍男女免费看全片| 今天免费中文字幕视频| 久久九九兔免费精品6| 亚洲AV福利天堂一区二区三| 国产一区二区免费视频| 国产亚洲人成无码网在线观看| 国产精品亚洲а∨无码播放麻豆 | 亚洲国产精品成人精品软件| 国产精品99精品久久免费| 亚洲不卡中文字幕无码| 成人无码精品1区2区3区免费看| 国产成人麻豆亚洲综合无码精品| 久久久WWW成人免费精品| 亚洲一区精品无码| 日韩精品极品视频在线观看免费 | 边摸边吃奶边做爽免费视频99| 成人亚洲综合天堂| 中文字幕免费视频精品一| 久久亚洲精品AB无码播放| h视频在线观看免费完整版| 亚洲人成色777777老人头| 男人的天堂亚洲一区二区三区 | 亚洲福利电影一区二区?| 无遮免费网站在线入口| 亚洲AV色无码乱码在线观看| 亚洲第一视频在线观看免费| 花蝴蝶免费视频在线观看高清版 | 99亚洲乱人伦aⅴ精品| 国产亚洲精品福利在线无卡一| 毛片免费在线观看| 亚洲一区二区三区在线网站| 亚洲?v无码国产在丝袜线观看 | 免费中文字幕在线观看| 男人天堂免费视频| 亚洲中文字幕无码久久2020| 亚洲色婷婷综合开心网| 久久午夜免费视频| 一区二区三区免费视频播放器| 久久亚洲国产精品成人AV秋霞| 日韩免费高清视频| 久久久久免费精品国产小说|