在linux下用nexus搭建maven私倉

jdk,maven不多說
下載Nexus Repository Manager 2 OSShttps://help.sonatype.com/repomanager2/download
土豪或者公司也可以去下PRO不解釋
上傳並移動到/home/data/nexus不解釋
上傳:https://blog.csdn.net/oLengYueHun/article/details/88798987
基礎命令:https://blog.csdn.net/oLengYueHun/article/details/88796736

下面將如何安裝
解壓

$: tar -zxvf nexus-2.14.12-02-bundle.tar.gz

目錄結構:
百度百度百度
更改訪問用戶:

vi nexus-2.14.12-02/bin/nexus

#RUN_AS_USER=改爲RUN_AS_USER=root

開放8081
firewall-cmd --zone=public --add-port=8081/tcp --permanent  
重啓防火牆
firewall-cmd --reload

在bin目錄下啓動nexus

./nexus start

瀏覽器打開遠程地址

https://192.168.1.110:8081/nexus

右上角登錄

username:admin
password:admin123

點擊Repositories,將列表中所有Type爲proxy 的項目的 Configuration 中的
Download Remote Indexes 設置爲True
將Releases倉庫的Deployment Policy設置爲 Allow ReDeploy

手工添加jar:
3rd party–>GAV:from pom
filename:鼠標選擇jar包
upload artifact(s)

配置本地項目引用私服
修改maven配置文件settings.xml

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

配置Maven從Nexus下載構件

在POM中配置Nexus私服,這樣的配置只對當前的Maven項目有效。

<!--指定Nexus的構件倉庫-->
<repositories>
    <repository>
        <id>public</id>
        <name>Team Maven Repository</name>
        <url>http://192.168.1.11:8081/nexus/content/groups/public/</url>
        <releases>
            <enabled>true</enabled>
        </releases>
        <snapshots>
            <enabled>true</enabled>
        </snapshots>
    </repository>
</repositories>
 
<!--指定Nexus的插件倉庫-->
<pluginRepositories>
    <pluginRepository>
        <id>public</id>
        <name>Team Maven Repository</name>
        <url>http://192.168.1.110:8081/nexus/content/groups/public/</url>
        <releases>
            <enabled>true</enabled>
        </releases>
        <snapshots>
            <enabled>true</enabled>
        </snapshots>
    </pluginRepository>
</pluginRepositories>
<!---------------------------------------------->
   項目pom.xml配置
<distributionManagement>
		<repository>
			<id>nexus-releases</id>
			<name>Nexus Release Repository</name>
			<url>http://192.168.1.110:8081/nexus/content/repositories/releases/</url>
		</repository>
		<snapshotRepository>
			<id>nexus-snapshots</id>
			<name>Nexus Snapshot Repository</name>
			<url>http://192.168.1.110:8081/nexus/content/repositories/snapshots/</url>
		</snapshotRepository>
</distributionManagement>
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章