linux下nexus+maven

1、https://www.sonatype.com/download-oss-sonatype下載2.14 tar.gz文件(3.0需要JDK8以上)

2、上傳安裝包到linux目錄下

3、解壓tar zxvf nexus-2.14.1-01-bundle.tar.gz

4、進入bin目錄下,輸入./nexus start(root用戶會出現以下問題,設置步驟參考步驟5)

****************************************
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.

5、進入/etc/profile修改環境變量export RUN_AS_USER=root

6、source profile使設置生效

7、進入nexus的bin目錄,./nexus start

****************************************
WARNING - NOT RECOMMENDED TO RUN AS ROOT
****************************************
Starting Nexus OSS...
Started Nexus OSS.

8、http://服務器IP:8081/nexus/(默認端口是8081)修改端口號:進入conf目錄,修改nexus.properties的端口

9、登錄,默認用戶名admin  密碼admin23

10、上傳jar包到私服






11、配置倉庫信息

 <repositories>  
        <repository>  
            <id>public</id>   與nexus的倉庫名對應(可通過nexus倉庫列表,查看configuration配置找到ID)
            <name>Public Repositories</name>  
            <url>http://IP:8081/nexus/content/groups/public/</url>  
            <releases>  
                <enabled>true</enabled>  
            </releases>  
            <snapshots>  
                <enabled>true</enabled>  
            </snapshots>  
        </repository>  
    </repositories>   
    <pluginRepositories>  
        <pluginRepository>  
            <id>public</id>  
            <name>Public Repositories</name>  
            <url>http://IP:8081/nexus/content/groups/public/</url>  
            <releases>  
                <enabled>true</enabled>  
            </releases>  
            <snapshots>  
                <enabled>true</enabled>  
            </snapshots>  
        </pluginRepository>  
    </pluginRepositories> 
<!-- 自動打包 通過jenkins上傳-->    
<distributionManagement>      
  <repository>         
   <id>releases</id><!--這個ID需要與你的release倉庫的Repository ID一致-->      
      <url>http://xxx.xx.xx.xx:8081/nexus/content/repositories/releases</url>    
    </repository>    
    <snapshotRepository>      
      <id>snapshots</id><!--這個ID需要與你的snapshots倉庫的Repository ID一致-->     
       <url>http://xxx.xx.xx.xx:8081/nexus/content/repositories/snapshots</url>    
    </snapshotRepository>   
 </distributionManagement>


12、設置deploy賬戶密碼

security-users-右鍵deployment

13、部署maven:

將linux安裝包上傳到文件夾

tat -zvxf 安裝文件名

進入加壓後的文件夾pwd獲取路徑
修改 /etc/profile文件,添加:
export MAVEN_HOME=上一步獲取的路徑
source /etc/profile

配置conf目錄下的setting.xml文件:

在<settings><profiles></profiles></settings>節點之間添加配置:

<profile>
<id>dev</id>
 <repositories>
 <repository> 
   <id>public</id> 與倉庫地址ID一致
   <url>http://192.168.6.204:8081/nexus/content/groups/public/</url>
 <releases

   <enabled>true</enabled>
 </releases> 
 <snapshots>
 <enabled>true</enabled>
 </snapshots> 
</repository>
</repositories>
 </profile>

接着在<settings></settings>節點之間添加配置:

<activeProfiles> 
<activeProfile>dev</activeProfile>
</activeProfiles>

<server>

<id>public</id>與倉庫地址ID一致

<username>deployment</username>

<password>123456</password><!--這個密碼就是你設置的密碼-->

</server>


<id>releases</id>

<username>deployment</username>

<password>123456</password><!--這個密碼就是你設置的密碼-->

</server>

<server>

<id>snapshots</id>

<username>deployment</username>

<password>123456</password><!--這個密碼就是你設置的密碼-->

</server>


以上配置好了連接Nexus私服。



14、運行發佈控制檯mvn clean deploy

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