首先需要配置远程仓库私服的服务器账号、密码,找到maven的settings.xml文件,配置<server>,里边的ID注意,就是标识你仓库的唯一ID,可以根据你的仓库随意起名就行。
<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>
-->
<!-- 在这里添加配置私仓的ID和账号、密码 -->
<server>
<id>mycentral</id>
<username>私服账号</username>
<password>私服密码</password>
</server>
<server>
<id>mysnapshots</id>
<username>私服账号</username>
<password>私服密码</password>
</server>
</servers>
然后找到你代码工程中的pom.xml文件,配置<distributionManagement>或<repositories>,这2个字段的区别就是
distributionManagement是使用mavne deploy上传打好的包。
repositories就跟打包上传无关,只是你想在POM中配置其它的远程仓库。文章来源:https://www.toymoban.com/news/detail-509903.html
所以你可以根据需要全部配置或只配置其中一个。注意其中的ID,一定要和你在settings.xml中配置server账号的ID保持一致,才能关联生效文章来源地址https://www.toymoban.com/news/detail-509903.html
<distributionManagement>
<repository>
<!--注意ID配置与settings.xml中server配置ID保持一致-->
<id>mycentral</id>
<name>Artifactory-releases</name>
<url>https://私仓地址.com.cn/artifactory/Management_Application_Maven</url>
</repository>
<snapshotRepository>
<id>mysnapshots</id>
<name>Artifactory-snapshots</name>
<url>https://私仓地址.com.cn/artifactory/Management_Application_Maven</url>
</snapshotRepository>
</distributionManagement>
<repositories>
<repository>
<!--注意ID配置与settings.xml中server配置ID保持一致-->
<id>mysnapshots</id>
<url>https://devstack.vgc.com.cn/artifactory/Timesheet_Management_Application_Maven</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
<repository>
<!--注意ID配置与settings.xml中server配置ID保持一致-->
<id>mycentral</id>
<url>https://devstack.vgc.com.cn/artifactory/Timesheet_Management_Application_Maven</url>
</repository>
<repository>
<id>alimaven</id>
<name>aliyun maven</name>
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
到了这里,关于maven配置远程仓库私服的服务器账号、密码的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!