一区二区三区在线-一区二区三区亚洲视频-一区二区三区亚洲-一区二区三区午夜-一区二区三区四区在线视频-一区二区三区四区在线免费观看

服務(wù)器之家:專注于服務(wù)器技術(shù)及軟件下載分享
分類導(dǎo)航

PHP教程|ASP.NET教程|Java教程|ASP教程|編程技術(shù)|正則表達(dá)式|C/C++|IOS|C#|Swift|Android|VB|R語言|JavaScript|易語言|vb.net|

服務(wù)器之家 - 編程語言 - Java教程 - 基于maven實現(xiàn)私服搭建步驟圖解

基于maven實現(xiàn)私服搭建步驟圖解

2020-08-05 16:17護(hù)花使者 Java教程

這篇文章主要介紹了基于maven實現(xiàn)私服搭建步驟圖解,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友可以參考下

私服是架設(shè)在局域網(wǎng)的一種特殊的遠(yuǎn)程倉庫。可以代理遠(yuǎn)程倉庫以及部署第三方構(gòu)件。

有了私服之后,當(dāng)maven下載構(gòu)件時,直接請求私服,私服上存在則下載到本地倉庫。否則會請求外部的遠(yuǎn)程倉庫,將構(gòu)建下載到私服,再提供給本地倉庫下載。基于maven實現(xiàn)私服搭建步驟圖解

構(gòu)建私服的軟件,我們這邊采用Sonatype Nexus

官網(wǎng):https://blog.sonatype.com/

基于maven實現(xiàn)私服搭建步驟圖解

基于maven實現(xiàn)私服搭建步驟圖解

解壓縮:

基于maven實現(xiàn)私服搭建步驟圖解

在bin下執(zhí)行:

./nexus.exe /run

訪問:8081端口,可以修改端口。

賬號:admin

密碼:admin123

基于maven實現(xiàn)私服搭建步驟圖解

maven-central:maven中央庫,默認(rèn)從https://repo1.maven.org/maven2/拉取jar

maven-releases:私庫發(fā)行版jar

maven-snapshots:私庫快照(調(diào)試版本)jar

maven-public:倉庫分組,把上面三個倉庫組合在一起對外提供服務(wù),在本地maven基礎(chǔ)配置settings.xml中使用。

有些jar在中心倉庫是沒有的,如oracle的驅(qū)動。

測試第三方j(luò)ar包,手動導(dǎo)入到私服中

基于maven實現(xiàn)私服搭建步驟圖解

可以看到已經(jīng)加載進(jìn)來了。

基于maven實現(xiàn)私服搭建步驟圖解

maven關(guān)聯(lián)私服

配置maven的setting文件:

1)配置賬號密碼

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|-->
 <servers>
  <!-- server
   | Specifies the authentication information to use when connecting to a particular server, identified by
   | a unique name within the system (referred to by the 'id' attribute below).
   |
   | NOTE: You should either specify username/password OR privateKey/passphrase, since these pairings are
   |    used together.
   |
  <server>
   <id>deploymentRepo</id>
   <username>repouser</username>
   <password>repopwd</password>
  </server>
  -->
 
  <!-- Another sample, using keys to authenticate.
  <server>
   <id>siteServer</id>
   <privateKey>/path/to/private/key</privateKey>
   <passphrase>optional; leave empty if not used.</passphrase>
  </server>
  -->
  <server>
    <id>nexus-public</id>
    <username>admin</username>
    <password>admin123</password>
  </server>
 </servers>

2)配置profile, 在<profiles></profiles>中添加, 這邊配置repository的id需要跟上面的server配置的id一樣,這樣才可以認(rèn)證通過。

?
1
2
3
4
5
6
7
8
9
10
11
12
<profile>
   <id>nexus</id>
   <repositories>
    <repository>
     <id>nexus-public</id>
     <name>private reposity</name>
     <url>http://localhost:8081/repository/maven-public/</url>
     <layout>default</layout>
     <snapshotPolicy>always</snapshotPolicy>
    </repository>
   </repositories>
  </profile>

3)使profile生效

?
1
2
3
<activeProfiles>
 <activeProfile>nexus</activeProfile>
</activeProfiles>

創(chuàng)建一個項目,添加依賴,可以看到把我們剛才手動加的jar給依賴過來了。

基于maven實現(xiàn)私服搭建步驟圖解

把maven項目部署到私服

這邊repository中配置的id需要跟maven setting中配置的server的id需要一樣。需要在本項目的pom.xml添加如下配置。

?
1
2
3
4
5
6
7
8
9
10
11
12
<distributionManagement>
  <repository>
    <id>nexus-public</id>
    <name>core release repository</name>
    <url>http://localhost:8081/repository/maven-releases/</url>
  </repository>
  <snapshotRepository>
    <id>nexus-public</id>
    <name>core snapshots repository</name>
    <url>http://localhost:8081/repository/maven-snapshots/</url>
  </snapshotRepository>
</distributionManagement>

執(zhí)行命令:

mvn deploy

需要等待執(zhí)行完畢。

基于maven實現(xiàn)私服搭建步驟圖解

這邊就可以看見,跑到私服里面來了。

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持服務(wù)器之家。

原文鏈接:https://www.cnblogs.com/chenmz1995/p/12802474.html

延伸 · 閱讀

精彩推薦
主站蜘蛛池模板: 果冻传媒九一制片厂网站 | 都市后宫小说 | 小妇人电影免费完整观看2021 | 边吃胸边膜下刺激免费男对女 | 啊好痛嗯轻一点免费 | 99在线在线视频免费视频观看 | 欧美成人一区二区三区 | 日本无遮挡亲吻膜下面免费 | 亚洲国产欧美日韩在线一区 | 精品国产成人a区在线观看 精品国产91久久久久久久 | 亚洲丁香网 | 欧洲美女女同 | 手机看片自拍自自拍日韩免费 | 無码一区中文字幕少妇熟女H | 亚洲视频在线观看免费视频 | 亚洲 另类 欧美 变态屎尿 | 韩国禁片在线观看久 | 日本中文字幕在线视频站 | 无码爽死成人777在线观看网站 | 亚洲国产网址 | 国产一久久香蕉国产线看观看 | 91小视频在线观看免费版高清 | 久久99国产精品二区不卡 | 我与旗袍老师疯狂床震 | 免费视频观看 | 91香蕉国产在线观看免费永久 | 国产良家| 999任你躁在线精品免费不卡 | 亚洲伦理影院 | 456在线观看 | 亚洲精品色综合久久 | 丰满岳乱妇在线观看视频国产 | 国产精品区一区二区免费 | 亚洲第一区欧美日韩精品 | 国模孕妇季玥337p人体 | 久久影院中文字幕 | 亚洲免费在线观看视频 | 亚洲2017天堂色无码 | 国产成人综合精品一区 | 日韩性事 | 色综合久久九月婷婷色综合 |