ALL is Well!

          敏捷是一條很長的路,摸索著前進著

            BlogJava :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理 ::
            30 隨筆 :: 23 文章 :: 71 評論 :: 0 Trackbacks

          搭建repository私服的用處有很多。
          除了如何如何管理好jar包外,還有就是當 maven2 無法自動獲取某個jar包時,(例如 oracle的jdbc jar包)
          我們需要手動下載此jar包,將其上傳至我們得私服,填寫groupId,artifactId,version等信息。
          然后再在pom.xml里進行依賴配置。

          我搭建私服的工具是artifactory-2.2.3。
          首先到網上下載artifactory-2.2.3,google一下,什么都有了。
          下載好后,將其解壓到任意目錄。
          由于artifactory自帶了Jetty Web服務器,所以,只要雙擊\bin\artifactory.bat 即可運行。(太方便了)
          待服務器啟動好后,用 http://localhost:8081/artifactory/ 開發頁面。
          默認的用戶名密碼是:admin/password.
          畫面如下:


          輸入用戶名:admin 密碼:password 登錄。

          進入畫面后,點擊Deploy,選擇要上傳的jar包。


          選中jar包后,點擊 Upload,會彈出 如下圖畫面:


          這里的GroupId、ArtifactId、Version便是要在pom.xml里添加依賴時指定的元素。
          同時,可以點擊POM Editor 來對它的 pom.xml進行編輯。如下代碼:

          <?xml version="1.0" encoding="UTF-8"?>
          <project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
              xmlns:xsi
          ="http://www.w3.org/2001/XMLSchema-instance">
            
          <modelVersion>4.0.0</modelVersion>
            
          <groupId>poi</groupId>
            
          <artifactId>poi</artifactId>
            
          <version>3.6</version>
            
          <description>Artifactory auto generated POM</description>
          </project>


          這還不算完!!這只是建立了repository私服,但是怎樣告訴maven在compile、package時去本地私服尋找依賴包呢?

          有兩種方式來配置,一是在settings.xml里指定,二是在項目的pom.xml中指定。

          我是在settings.xml中進行指定,在settings.xml文件中,加入Profile節點。
          (關于此節點的說明,請參見:http://www.aygfsteel.com/jnbzwm/archive/2010/09/03/330862.html


          <profiles>
              
          <profile>
                
          <id>localrepo</id>
                
          <activation>
                  
          <jdk>1.6</jdk>
                
          </activation>
                
          <repositories>
                  
          <repository>
                    
          <id>central</id>
                    
          <name>artifactory at local</name>
                    
          <url>http://localhost:8081/artifactory/repo</url>
                    
          <layout>default</layout>
                    
          <snapshots>   
                      
          <enabled>false</enabled>   
                   
          </snapshots>
                  
          </repository>
                  
          <repository>   
                   
          <id>snapshots</id>   
                    
          <url>http://localhost:8081/artifactory/repo</url>   
                     
          <releases>   
                      
          <enabled>false</enabled>   
                     
          </releases>   
                  
          </repository>
                
          </repositories>
                
          <pluginRepositories>
                  
          <pluginRepository>
                      
          <id>artifactory</id>
                      
          <name>artifactory plugins at local </name>
                      
          <url>http://localhost:8081/artifactory/plugins-releases</url>
                      
          <snapshots>
                          
          <enabled>false</enabled>
                      
          </snapshots>
                  
          </pluginRepository>
              
          </pluginRepositories>
          </profiles>

          在前一個學習筆記中有提到,配置profile后,需要進行激活,所以再在settings.xml中,加入activeProfiles節點的配置。

            <activeProfiles>
              
          <activeProfile>localrepo</activeProfile>
            
          </activeProfiles>

          這里指定的localrepo 就是我們配置的profile的Id。

          到此,配置結束。


          本文為原創,歡迎轉載,轉載請注明出處BlogJava
          posted on 2010-09-03 14:15 李 明 閱讀(897) 評論(0)  編輯  收藏 所屬分類: Maven2
          主站蜘蛛池模板: 新野县| 乐东| 潮安县| 孝义市| 招远市| 寻甸| 清远市| 娱乐| 中西区| 肥西县| 呼和浩特市| 玉环县| 沙河市| 巴里| 林周县| 五莲县| 大冶市| 精河县| 全南县| 安庆市| 新竹市| 新建县| 河北省| 衡阳县| 长子县| 彭州市| 吉木乃县| 紫金县| 广元市| 平利县| 香港| 田阳县| 林周县| 马龙县| 鹤庆县| 资中县| 陕西省| 纳雍县| 定陶县| 龙井市| 桦南县|