1. 程式人生 > >Linux搭建nexus私人倉庫,並上傳下載maven jar

Linux搭建nexus私人倉庫,並上傳下載maven jar

1.nexus私人倉庫安裝啟動

# 下載nexus
https://download.sonatype.com/nexus/oss/nexus-2.14.10-01-bundle.tar.gz

tar -zvxf nexus-2.14.10-01-bundle.tar.gz

# 修改RUN_AS_USER
vim bin/nexus
RUN_AS_USER=root     
         
# 啟動nexus
./bin/nexus start 

# 訪問
http://172.22.2.133:8081/nexus/
使用者名稱: admin 密碼: admin123

2.上傳maven jar

# 本地maven配置
<server>
    <id>releases</id>
    <username>admin</username>
    <password>admin123</password>
</server>
<server>
    <id>snapshots</id>
    <username>admin</username>
    <password>admin123</password>
</server>

# maven原始碼pom.xml檔案新增配置
<distributionManagement>
    <repository>
        <id>releases</id>
        <url>http://172.22.2.133:8081/nexus/content/repositories/releases/</url>
    </repository>

    <snapshotRepository>
        <id>snapshots</id>
        <url>http://172.22.2.133:8081/nexus/content/repositories/snapshots/</url>
    </snapshotRepository>
</distributionManagement>

# 上傳
mvn deploy

3.下載Maven jar

# 本地Maven配置
<profiles>   
    <profile>   
        <id>activeProfile</id>   
        <repositories>   
            <repository>  
                <id>public</id>   
                <url>http://172.22.2.133:8081/nexus/content/groups/public/</url>   
                <releases>   
                    <enabled>true</enabled>   
                </releases>
                <snapshots>   
                    <enabled>true</enabled>   
                </snapshots>   
            </repository>   
        </repositories>  
        <pluginRepositories>  
            <pluginRepository>  
                <id>public</id>  
                <url>http://172.22.2.133:8081/nexus/content/groups/public/</url>  
            </pluginRepository>  
        </pluginRepositories>  
    </profile>  
</profiles>

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