特別說明
當(dāng)前博客平臺賬號已廢棄,如果有使用細節(jié)問題請前往我新博客平臺進行討論交流。
個人博客平臺 HuRuWo的技術(shù)小站
文章首發(fā)于個人博客HuRuWo的技術(shù)小站,如果本文非vip用戶無法完全瀏覽或者圖片無法打開延届,可前往個人博客文章地址查看文章并留言討論恨胚。
個人博客文章地址搭建本地的nexus-maven-倉庫
更多技術(shù)文章訪問本人博客HuRuWo的技術(shù)小站贪绘,包括 Electron從零開發(fā) Android 逆向 app 微信數(shù)據(jù)抓取 抖音數(shù)據(jù)抓取 閑魚數(shù)據(jù)抓取 小紅書數(shù)據(jù)抓取 其他軟件爬蟲 等技術(shù)文章
下載搭建的文件
![Paste_Image.png](https://upload-images.jianshu.io/upload_images/6506204-8a7929c4ca45076a.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
Paste_Image.png
找到合適的版本文件夾:
![Paste_Image.png](https://upload-images.jianshu.io/upload_images/6506204-c499caae6acaf88a.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
Paste_Image.png
修改配置文件
![Paste_Image.png](https://upload-images.jianshu.io/upload_images/6506204-fa957a7f8bda4570.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
Paste_Image.png
wrapper.java.command=java
配置java的環(huán)境變量即可徘键。
點擊console-nexus.bat
,運行服務(wù)器
![Paste_Image.png](https://upload-images.jianshu.io/upload_images/6506204-39a551462487c7f0.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
Paste_Image.png
訪問:http://localhost:8081/nexus
![Paste_Image.png](https://upload-images.jianshu.io/upload_images/6506204-7c128cc14df93e9e.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
Paste_Image.png
右上角登陸,賬號密碼 admin,admin123
新建倉庫
點擊repositories
![Paste_Image.png](https://upload-images.jianshu.io/upload_images/6506204-442a5c998f9e3620.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
Paste_Image.png
內(nèi)置的幾個倉庫說明:
- Releases:這里存放我們自己項目中發(fā)布的構(gòu)建, 通常是Release版本的, 比如我們自己做了一個FTP Server的項目, 生成的構(gòu)件為ftpserver.war, 我們就可以把這個構(gòu)建發(fā)布到Nexus的Releases本地倉庫. 關(guān)于符合發(fā)布后面會有介紹.
- Snapshots:這個倉庫非常的有用, 它的目的是讓我們可以發(fā)布那些非release版本, 非穩(wěn)定版本, 比如我們在trunk下開發(fā)一個項目,在正式release之前你可能需要臨時發(fā)布一個版本給你的同伴使用, 因為你的同伴正在依賴你的模塊開發(fā), 那么這個時候我們就可以發(fā)布Snapshot版本到這個倉庫, 你的同伴就可以通過簡單的命令來獲取和使用這個臨時版本.
- 3rd Party:顧名思義, 第三方庫, 你可能會問不是有中央倉庫來管理第三方庫嘛,沒錯, 這里的是指可以讓你添加自己的第三方庫, 比如有些構(gòu)件在中央倉庫是不存在的. 比如你在中央倉庫找不到Oracle 的JDBC驅(qū)動, 這個時候我們就需要自己添加到3rdparty倉庫。
新建自己的倉庫,可選好幾種類型的倉庫遍蟋。
![Paste_Image.png](https://upload-images.jianshu.io/upload_images/6506204-84f3b2df714513b7.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
Paste_Image.png
-
hosted
吹害,本地倉庫,通常我們會部署自己的構(gòu)件到這一類型的倉庫虚青。比如公司的第二方庫它呀。 -
proxy
,代理倉庫棒厘,它們被用來代理遠程的公共倉庫纵穿,如maven中央倉庫。 -
group
奢人,倉庫組谓媒,用來合并多個hosted/proxy倉庫,當(dāng)你的項目希望在多個repository使用資源時就不需要多次引用了何乎,只需要引用一個group即可句惯。 -
virtual
虛擬倉庫,用得少
使用新增的倉庫
編寫build.gradle
文件:
group = 'com.mrzhang.andcomponent'
version = '0.0.3'
uploadArchives {
repositories {
mavenDeployer {
repository(url: uri('http://localhost:8081/nexus/content/repositories/TestDemo'))
{
authentication(userName: "admin", password: "admin123")
}
}
}
}
然后點擊uploadArchives
![Paste_Image.png](https://upload-images.jianshu.io/upload_images/6506204-da2ab2e6ba9eb864.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
Paste_Image.png
成功之后就能看到倉庫里出現(xiàn)了:
![Paste_Image.png](https://upload-images.jianshu.io/upload_images/6506204-8d76e83c0bb9c3fe.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
Paste_Image.png
如何引用:
這是一個apply plugin
插件支救,在根部引用:
![Paste_Image.png](https://upload-images.jianshu.io/upload_images/6506204-9574c9e5530912a6.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
Paste_Image.png
相關(guān)異常處理
Error:Execution failed for task ':build-gradle:uploadArchives'.
> Could not publish configuration 'archives'
> Failed to deploy artifacts: Could not transfer artifact com.mrzhang.andcomponent:build-
gradle:jar:0.0.3 from/to remote (http://localhost:8081/nexus/content/repositories/TestDemo):
Failed to transfer file: http://localhost:8081/nexus/content/repositories/TestDemo/com/mrzhang/andcomponent/build-
gradle/0.0.3/build-gradle-0.0.3.jar. Return code is: 400, ReasonPhrase: Bad Request.
發(fā)布版本沖突: 因為倉庫已經(jīng)有相同版本的jar包抢野。
解決辦法:
1.修改版本號:version = '0.0.1'
2.設(shè)置強制覆蓋原來的jar包:
![Paste_Image.png](https://upload-images.jianshu.io/upload_images/6506204-cf5f53546c9b4408.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
Paste_Image.png