maven nexus 搭建私服

Nexus 網站 http://www.sonatype.org/nexus/

nexus-2.11.2-06-bundle.tar.gz

解壓下載的文件:

tar -zxvf nexus-2.11.2-06-bundle.tar.gz 

解壓後目錄:


nexus-oss-webapp-1.8.0.1 包含了nexus的運行環境和應用程序

 

sonatype-work 包含了你自己的配置和數據

啓動nexus

 

進入nexus-oss-webapp-1.8.1目錄

 


./nexus start

訪問:http://192.168.21.36:8081/nexus

用戶名:admin 密碼:admin123


配置Nexus

 


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

 

 

 

 

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

 


download remote indexes 設置爲true 在線下載索引

也可以自己拷貝索引 從網上下載

 

 

 三、在項目中使用私服

 

在完成了上面的配置後,就可以將項目中默認的Repository切換爲本地的私服了,只需要在pom.xml中增加repositories就可以了:

 

  1. <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
  2.   xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">  
  3.   <modelVersion>4.0.0</modelVersion>  
  4.   
  5.   <groupId>com.mycom.test</groupId>  
  6.   <artifactId>simple</artifactId>  
  7.   <version>0.0.1-SNAPSHOT</version>  
  8.   <packaging>jar</packaging>  
  9.   
  10.   <name>simple</name>  
  11.   <url>http://maven.apache.org</url>  
  12.   
  13.   <repositories>    
  14.     <repository>    
  15.       <snapshots>    
  16.         <enabled>true</enabled>    
  17.       </snapshots>    
  18.       <id>public</id>    
  19.       <name>Public Repositories</name>    
  20.       <url>http://192.168.1.7:8081/nexus/content/groups/public/</url>    
  21.     </repository>    
  22.   </repositories>  
  23.   <pluginRepositories>    
  24.     <pluginRepository>    
  25.       <id>public</id>    
  26.       <name>Public Repositories</name>    
  27.       <url>http://192.168.1.7:8081/nexus/content/groups/public//</url>    
  28.     </pluginRepository>    
  29.   </pluginRepositories>    
  30.   <properties>  
  31.     <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>  
  32.   </properties>  
  33.   
  34.   <dependencies>  
  35.     <dependency>  
  36.       <groupId>junit</groupId>  
  37.       <artifactId>junit</artifactId>  
  38.       <version>3.8.1</version>  
  39.       <scope>test</scope>  
  40.     </dependency>  
  41.   </dependencies>  
  42. </project>  

 

將pom.xml保存後,再回過頭來了看去nexus管理界面看,就會發現junit已經被下載到本地的nexus服務器中了。

http://www.cnblogs.com/quanyongan/archive/2013/04/24/3037589.html

http://www.cnblogs.com/adolfmc/archive/2012/08/21/2648415.html


安裝私服nexus遇到的問題  

2013-11-02 08:07:33|  分類: maven|舉報|字號 訂閱

問題:啓動maven私服nexus時報錯

[root@localhost bin]# ./nexus start
****************************************
WARNING - NOT RECOMMENDED TO RUN AS ROOT
****************************************
If you insist running as root, then set the environment variable RUN_AS_USER=root before running this script.


解決方法:修改vi nexus 的 RUN_AS_USER=root


================================================================================

問題:無法啓動。

解決方法:通 過 ./nexus start啓動時,會自動退出。通過./nexus console查看,發現由於jdk版本造成的,原本是應該升級jdk6到jdk7,但因爲服務器同時還有其他項目,怕受影響,所以降低了nexus版本,從nexus-2.6.4-02降到nexus-2.3.0-04,訪問http://192.168.1.52:8081/nexus正常,問題解決


https://repo1.maven.org/maven2/


windows 起不來,如下原因是因爲沒有配java運行環境


 

wrapper.java.command=C:\Program Files (x86)\Java\jdk1.7.0_21\bin\java



發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章