免费视频淫片aa毛片_日韩高清在线亚洲专区vr_日韩大片免费观看视频播放_亚洲欧美国产精品完整版

打開APP
userphoto
未登錄

開通VIP,暢享免費電子書等14項超值服

開通VIP
maven配置篇之settings.xml
  maven2 比起maven1 來說,需要配置的文件少多了,主要集中在pom.xml和settings.xml中。
    先來說說settings.xml,settings.xml對于maven來說相當(dāng)于全局性的配置,用于所有的項目。在maven2中存在兩個settings.xml,一個位于maven2的安裝目錄conf下面,作為全局性配置。對于團隊設(shè)置,保持一致的定義是關(guān)鍵,所以maven2/conf下面的settings.xml就作為團隊共同的配置文件。保證所有的團隊成員都擁有相同的配置。當(dāng)然對于每個成員,都需要特殊的自定義設(shè)置,如用戶信息,所以另外一個settings.xml就作為本地配置。默認的位置為:${user.dir}/.m2/settings.xml目錄中(${user.dir} 指windows 中的用戶目錄)。
    settings.xml基本結(jié)構(gòu)如下:
    <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:表示本地庫的保存位置,也就是maven2主要的jar保存位置,默認在${user.dir}/.m2/repository,如果需要另外設(shè)置,就換成其他的路徑。
offline:如果不想每次編譯,都去查找遠程中心庫,那就設(shè)置為true。當(dāng)然前提是你已經(jīng)下載了必須的依賴包。
Servers
   在POM中的 distributionManagement元素定義了開發(fā)庫。然而,特定的username和pwd不能使用于pom.xml,所以通過此配置來保存server信息
  <servers>
    <server>
      <id>server001</id>
      <username>my_login</username>
      <password>my_password</password>
      <privateKey>${usr.home}/.ssh/id_dsa</privateKey>
      <passphrase>some_passphrase</passphrase>
      <filePermissions>664</filePermissions>
      <directoryPermissions>775</directoryPermissions>
      <configuration></configuration>
    </server>
  </servers>
  • id:server 的id,用于匹配distributionManagement庫id,比較重要。
  • username, password:用于登陸此服務(wù)器的用戶名和密碼
  • privateKey, passphrase:設(shè)置private key,以及passphrase
  • filePermissions, directoryPermissions:當(dāng)庫文件或者目錄創(chuàng)建后,需要使用權(quán)限進行訪問。參照unix文件許可,如664和775
Mirrors
表示鏡像庫,指定庫的鏡像,用于增加其他庫
  <mirrors>
    <mirror>
      <id>planetmirror.com</id>
      <name>PlanetMirror Australia</name>
      <url>http://downloads.planetmirror.com/pub/maven2</url>
      <mirrorOf>central</mirrorOf>
    </mirror>
  </mirrors>
  • id,name:唯一的標志,用于區(qū)別鏡像
  • url:鏡像的url
  • mirrorOf:此鏡像指向的服務(wù)id
Proxies
此設(shè)置,主要用于無法直接訪問中心的庫用戶配置。
  <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>
  </proxies>
  • id:代理的標志
  • active:是否激活代理
  • protocol, host, port:protocol://host:port 代理
  • username, password:用戶名和密碼
  • nonProxyHosts: 不需要代理的host
Profiles
  類似于pom.xml中的profile元素,主要包括activation,repositories,pluginRepositories 和properties元素
  剛開始接觸的時候,可能會比較迷惑,其實這是maven2中比較強大的功能。從字面上來說,就是個性配置。
  單獨定義profile后,并不會生效,需要通過滿足條件來激活。
 repositories 和pluginRepositories
 定義其他開發(fā)庫和插件開發(fā)庫。對于團隊來說,肯定有自己的開發(fā)庫??梢酝ㄟ^此配置來定義。
 如下的配置,定義了本地開發(fā)庫,用于release 發(fā)布。
    <repositories>
        <repository>
          <id>repo-local</id>
       <name>Internal 開發(fā)庫</name>
       <url>http://192.168.0.2:8082/repo-local</url>
          <releases>
            <enabled>true</enabled>
            <updatePolicy>never</updatePolicy>
            <checksumPolicy>warn</checksumPolicy>
          </releases>
          <snapshots>
            <enabled>false</enabled>
          </snapshots>
          <layout>default</layout>
        </repository>
      </repositories>
      <pluginRepositories>
    <pluginRepository>
    <id>repo-local</id>
    <name>Internal 開發(fā)庫</name>
    <url>http://192.168.0.2:8082/repo-local</url>
    <releases>
            <enabled>true</enabled>
            <updatePolicy>never</updatePolicy>
            <checksumPolicy>warn</checksumPolicy>
    </releases>
    <snapshots>
    <enabled>false</enabled>
    </snapshots>
    <layout>default</layout>
    </pluginRepository>
    </pluginRepositories>
releases, snapshots:每個產(chǎn)品的版本的Release或者snapshot(注:release和snapshot的區(qū)別,release一般是比較穩(wěn)定的版本,而snapshot基本上不穩(wěn)定,只是作為快照)

properties
  maven 的properties作為placeholder值,如ant的properties。
包括以下的5種類型值:
  1. env.X,返回當(dāng)前的環(huán)境變量
  2. project.x:返回pom中定義的元素值,如project.version
  3. settings.x:返回settings.xml中定義的元素
  4. java 系統(tǒng)屬性:所有經(jīng)過java.lang.System.getProperties()返回的值
  5. x:用戶自己設(shè)定的值
Activation
  用于激活此profile
  <activation>
        <activeByDefault>false</activeByDefault>
        <jdk>1.5</jdk>
        <os>
          <name>Windows XP</name>
          <family>Windows</family>
          <arch>x86</arch>
          <version>5.1.2600</version>
        </os>
        <property>
          <name>mavenVersion</name>
          <value>2.0.3</value>
        </property>
        <file>
          <exists>${basedir}/file2.properties</exists>
          <missing>${basedir}/file1.properties</missing>
        </file>
      </activation>
  • jdk:如果匹配指定的jdk版本,將會激活
  • os:操作系統(tǒng)
  • property:如果maven能檢測到相應(yīng)的屬性
  • file: 用于判斷文件是否存在或者不存在

除了使用activation來激活profile,同樣可以通過activeProfiles來激活
Active Profiles
表示激活的profile,通過profile id來指定。
  <activeProfiles>
    <activeProfile>env-test</activeProfile> 指定的profile id
  </activeProfiles>
本站僅提供存儲服務(wù),所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點擊舉報。
打開APP,閱讀全文并永久保存 查看更多類似文章
猜你喜歡
類似文章
【Maven】Nexus配置和使用
Java技術(shù)學(xué)習(xí)筆記:Maven安裝和作用
【Maven用戶手冊】Maven之setting.xml配置文件詳解
上傳jar包到nexus私服
maven安裝和eclipse集成以及Maven之setting.xml配置文件詳解
私服相關(guān)配置
更多類似文章 >>
生活服務(wù)
分享 收藏 導(dǎo)長圖 關(guān)注 下載文章
綁定賬號成功
后續(xù)可登錄賬號暢享VIP特權(quán)!
如果VIP功能使用有故障,
可點擊這里聯(lián)系客服!

聯(lián)系客服