maven配置远程仓库私服的服务器账号、密码

博客介绍了Maven远程仓库私服的配置方法。先在settings.xml文件中配置服务器账号、密码及<server>,ID可随意命名。再在代码工程的pom.xml文件中配置<distributionManagement>或<repositories>,二者用途有别,ID需与settings.xml中保持一致。

首先需要配置远程仓库私服的服务器账号、密码,找到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中配置其它的远程仓库。

所以你可以根据需要全部配置或只配置其中一个。注意其中的ID,一定要和你在settings.xml中配置server账号的ID保持一致,才能关联生效

<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>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值