`
zhaohaolin
  • 浏览: 985070 次
  • 性别: Icon_minigender_1
  • 来自: 杭州
社区版块
存档分类
最新评论

maven下nexus的搭建,jar包上傳等注意事項

阅读更多

nexus是用來搭建本地jar包服務器到,具體就不多說了。
主要是參考裡下面到帖子。在此感謝作者。

持續集成之路——搭建Maven私服

Maven倉庫管理-Nexus(轉帖後加強版)

nexus的安裝

1.nexus的下載地址

http://nexus.sonatype.org/downloads/
我下載的是nexus-oss-webapp-1.8.0-bundle.tar.gz

解壓後得到2個文件:nexus-oss-webapp-1.8.0 和sonatype-work
前者包含了nexus的運行環境和應用程序,後者包含了你自己的配置和數據。

2.啟動nexus

在上面提到,nexus的運行環境在nexus-oss-webapp-1.8.0目錄,下面就進入這個目錄啟動:

# cd nexus-oss-webapp-1.8.0/bin/jsw/linux-x86-32/ 



在這個目錄下包含了一個文件夾和三個文件:lib、nexus、platform和wrapper,其中nexus就是啟動命令。

執行

 # ./nexus 


得到nexus到提示命令  如start,stop,status,restart 等。

輸入

 # ./nexus start 



終端出現

 Starting Nexus OSS...
Started Nexus OSS 


說明nexus啟動成功

注意:jsw文件夾下有很多針對不同操作系統到文件夾,選中適合自己操作系統的文件夾。
也可以把start,stop做成腳本放在桌面上,避免不停的cd
附件為start和stop的腳本,請打開腳本修改自己本機上nexus的路徑。

3.打開nexus

在瀏覽器中訪問: http://localhost:8081/nexus

出現


點擊右上角的login in
輸入帳號:admin
輸入密碼:admin123
登錄成功

配置nexus


由於在新搭建的nexus環境中只是一個空的倉庫,所以第一步就是要和遠程的Maven中心倉庫進行同步。





如果在Reindex之後,並沒有同步到遠程的倉庫,可以檢查每個倉庫的設置。下面是Maven Central的設置:





開打maven目錄-> conf -> settings.xml

找到localRepository
上面到註釋信息寫道:Default: ~/.m2/repository
我們可以添加

 <localRepository>${M3_HOME}/repository</localRepository> 



${M3_HOME}是maven到安裝路徑,新建個repository文件夾用來裝入本地的jar包

順手把以前默認的repository刪除。

 #cd ~
#rm -rf .m2 



依次在settings.xml文件裡輸入

 <!-- nexus帳號和密碼-->

   <server>  
     <id>nexus-releases</id>  
     <username>admin</username>  
     <password>admin123</password>  
   </server>  
   <server>  
     <id>nexus-snapshots</id>  
     <username>admin</username>  
     <password>admin123</password>  
   </server>     
 </servers>  

...

<!-- 引用naxus倉庫組-->
   <profile>
       <id>dev</id>
          <repositories>
             <repository>
                 <id>nexus</id>
                 <url>http://127.0.0.1:8081/nexus/content/groups/public/</url>
                 <releases>
                    <enabled>true</enabled>
                 </releases>
                 <snapshots>
                    <enabled>true</enabled>
                 </snapshots>
              </repository>
            </repositories>           
            <pluginRepositories>
                <pluginRepository>
                    <id>nexus</id>
                    <url>http://127.0.0.1:8081/nexus/content/groups/public</url>
                    <releases>
                        <enabled>true</enabled>
                    </releases>
                    <snapshots>
                        <enabled>true</enabled>
                    </snapshots>
                </pluginRepository>
            </pluginRepositories>
        </profile>
..

 <!-- nexus -->
  <activeProfiles>
        <activeProfile>dev</activeProfile>

    </activeProfiles> 



注意:根據標籤位置準確輸入

上傳jar到本地倉庫





選中3rd party 點擊Artifact Upload標籤點擊select artifact(s) 按鈕選擇要上傳到jar包然後再add artiffact -> uplaod artiffact 即可。

編輯pom.xml的時候可能找不到在nexus的jar包
<br />

在nexus裡查詢本地上傳的jar包複製xml代碼到pom.xml文件保存即可。

編輯好pom.xml後保存
完畢後在${M3_HOME}/repository 文件裡可看到導入的jar包。


分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics