倉庫介紹
阿里云Maven中央倉庫為 阿里云云效 提供的公共代理倉庫,幫助研發(fā)人員提高研發(fā)生產(chǎn)效率,使用阿里云Maven中央倉庫作為下載源,速度更快更穩(wěn)定。阿里云云效是企業(yè)級一站式 DevOps 平臺,覆蓋產(chǎn)品從需求到運營的研發(fā)全生命周期,其中云效也提供了免費、可靠的Maven私有倉庫 Packages,歡迎您體驗使用。
阿里云倉庫的使用
進入阿里云倉庫,未注冊的需要注冊后才能使用;
https://devops.aliyun.com/workbench
在云效中選擇制品倉庫
?
?選擇生產(chǎn)庫進入,點擊倉庫指南查看官方給的推送以及拉取方式;
推送?
這里以第二種推送方法為例,下載setting.xml文件并粘貼到maven路徑的conf文件下;
?setting中配置maven
?pom.xml文件中添加,url可以根據(jù)前面下載的setting.xml中的地址來復制;
<distributionManagement>
<repository>
<id>rdc-releases</id>
<name>rdc-releases</name>
<url>https://packages.aliyun.com/maven/repository/2294427-release-omAWMW/</url>
</repository>
<snapshotRepository>
<id>rdc-snapshots</id>
<name>rdc-snapshots</name>
<url>https://packages.aliyun.com/maven/repository/2294427-snapshot-VD6Bpi/</url>
</snapshotRepository>
</distributionManagement>
在idea控制臺中執(zhí)行以下命令進行發(fā)布:?
mvn clean deploy -DskipTests
云效默認為你提供了兩個倉庫:
Maven Release 庫用于存儲功能趨于穩(wěn)定、當前更新停止,可以用于發(fā)行的版本。
Maven Snapshot 庫用于存儲不穩(wěn)定、尚處于開發(fā)中的版本,即快照版本。
您的制品文件具體推送到哪個庫,根據(jù)您項目目錄的pom.xml文件中<version></version>字段中是否配置了-SNAPSHOT。
推送至 Release 庫pom.xml示例:
<groupId>com.example.xxxx</groupId>
<artifactId>xxxx</artifactId>
<version>1.0</version>
推送至 Snapshot 庫pom.xml示例:
<groupId>com.example.xxxx</groupId>
<artifactId>xxxx</artifactId>
<version>1.0-SNAPSHOT</version>
拉?。?/h2>
在阿里云maven包列表中復制依賴到pom.xml中;
?控制臺中執(zhí)行以下命令:
mvn install
上傳時的常見報錯
1、若發(fā)布時出現(xiàn)報錯:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:
2.7:deploy (default-deploy) on project testalibab: Deployment failed: repository
element was not specified in the POM inside distributionManagement element or
in -DaltDeploymentRepository=id::layout::url parameter -> [Help 1]
原因是因為pom.xml中缺少distributionManagement標簽配置
<distributionManagement>
<repository>
<id>rdc-releases</id>
<name>rdc-releases</name>
<url>https://packages.aliyun.com/maven/repository/2294427-release-omAWMW/</url>
</repository>
<snapshotRepository>
<id>rdc-snapshots</id>
<name>rdc-snapshots</name>
<url>https://packages.aliyun.com/maven/repository/2294427-snapshot-VD6Bpi/</url>
</snapshotRepository>
</distributionManagement>
2、若發(fā)布時出現(xiàn)報錯:
Not authorized , ReasonPhrase:Unauthorized
由于maven默認的settings file路徑是在C盤。所以將前面下載的setting.xml文件粘貼到以下路徑,即可解決;
?再次進行發(fā)布就可以發(fā)布成功了;
3、若發(fā)布時出現(xiàn)報錯:文章來源:http://www.zghlxwxcb.cn/news/detail-400966.html
不再支持源選項 5。請使用 7 或更高版本。
則在pom.xml中添加以下標簽即可解決,版本可根據(jù)自己的jdk進行選擇;文章來源地址http://www.zghlxwxcb.cn/news/detail-400966.html
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
</properties>
到了這里,關于阿里云maven倉庫的使用詳解以及報錯解決方法的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關文章,希望大家以后多多支持TOY模板網(wǎng)!