maven deploy distributionManagement
生活随笔
收集整理的這篇文章主要介紹了
maven deploy distributionManagement
小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
分發(fā)構(gòu)件至遠(yuǎn)程倉(cāng)庫(kù)mvn install?會(huì)將項(xiàng)目生成的構(gòu)件安裝到本地Maven倉(cāng)庫(kù),mvn deploy?用來(lái)將項(xiàng)目生成的構(gòu)件分發(fā)到遠(yuǎn)程Maven倉(cāng)庫(kù)。本地Maven倉(cāng)庫(kù)的構(gòu)件只能供當(dāng)前用戶使用,在分發(fā)到遠(yuǎn)程Maven倉(cāng)庫(kù)之后,所有能訪問(wèn)該倉(cāng)庫(kù)的用戶都能使用你的構(gòu)件。我們需要配置POM的distributionManagement來(lái)指定Maven分發(fā)構(gòu)件的位置,如下:Xml代碼?<project>???? ??...???? ??<distributionManagement>???? ????<repository>???? ??????<id>nexus-releases</id>???? ??????<name>Nexus?Release?Repository</name>???? ??????<url>http://127.0.0.1:8080/nexus/content/repositories/releases/</url>???? ????</repository>???? ????<snapshotRepository>???? ??????<id>nexus-snapshots</id>???? ??????<name>Nexus?Snapshot?Repository</name>???? ??????<url>http://127.0.0.1:8080/nexus/content/repositories/snapshots/</url>???? ????</snapshotRepository>???? ??</distributionManagement>???? ??...???? </project>???? Maven區(qū)別對(duì)待release版本的構(gòu)件和snapshot版本的構(gòu)件,snapshot為開(kāi)發(fā)過(guò)程中的版本,實(shí)時(shí),但不穩(wěn)定,release版本則比較穩(wěn)定。Maven會(huì)根據(jù)你項(xiàng)目的版本來(lái)判斷將構(gòu)件分發(fā)到哪個(gè)倉(cāng)庫(kù)。一般來(lái)說(shuō),分發(fā)構(gòu)件到遠(yuǎn)程倉(cāng)庫(kù)需要認(rèn)證,如果你沒(méi)有配置任何認(rèn)證信息,你往往會(huì)得到401錯(cuò)誤。這個(gè)時(shí)候,如下在settings.xml中配置認(rèn)證信息:Xml代碼?<settings>???? ??...???? ??<servers>???? ????<server>???? ??????<id>nexus-releases</id>???? ??????<username>admin</username>???? ??????<password>admin123</password>???? ????</server>???? ????<server>???? ??????<id>nexus-snapshots</id>???? ??????<username>admin</username>???? ??????<password>admin123</password>???? ????</server>?????? ??</servers>???? ??...???? </settings>?? 需要注意的是,settings.xml中server元素下id的值必須與POM中repository或snapshotRepository下id的值完全一致。將認(rèn)證信息放到settings下而非POM中,是因?yàn)镻OM往往是它人可見(jiàn)的,而settings.xml是本地的。
如果這里不配置,會(huì)報(bào)錯(cuò):?報(bào) 錯(cuò):Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.5:deploy (default-deploy) on project git-demo: Deployment failed: repository element was not specified in the POM inside distributionManagement element or in -DaltDeploymentRepository=id::layout::url parameter
小結(jié)
本文介紹了Maven倉(cāng)庫(kù),它是什么?本地倉(cāng)庫(kù),遠(yuǎn)程倉(cāng)庫(kù),中央倉(cāng)庫(kù)具體是指什么?并介紹了如何在POM中配置項(xiàng)目層次的倉(cāng)庫(kù),在settings中配置用戶層次的倉(cāng)庫(kù),以及mirror。本文還介紹了如何安裝構(gòu)件到本地倉(cāng)庫(kù),如何分發(fā)構(gòu)件至倉(cāng)庫(kù)。如果這里不配置,會(huì)報(bào)錯(cuò):?報(bào) 錯(cuò):Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.5:deploy (default-deploy) on project git-demo: Deployment failed: repository element was not specified in the POM inside distributionManagement element or in -DaltDeploymentRepository=id::layout::url parameter
總結(jié)
以上是生活随笔為你收集整理的maven deploy distributionManagement的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: rsync同步服务部署
- 下一篇: 阿里云的羊毛如何薅?创业者看过来!