原创

eclispe maven 自动发布更新远程私有仓库

远程仓库更新命令如下:

clean package deploy


1、配置账号密码,如下:

<?xml version="1.0" encoding="UTF-8"?>

<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" 
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
          xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
  ...
  <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>releases</id>
      <username>admin</username>
      <password>admin123</password>
    </server>
	<server>
      <id>snapshots</id>
      <username>admin</username>
      <password>admin123</password>
    </server>
  </servers>
  ...
</settings>


2、配置pom.xml文件

注意这里的id要和pom.xml里远程deploy的地址对应一致,pom.xml配置,如下:

<!-- 配置远程发布到私服,clean package deploy -->  

<distributionManagement>
 	<repository>
        <id>releases</id>
        <name>Nexus Release Repository</name>
        <url>http://192.168.20.229:8081/nexus/content/repositories/releases/</url>
 </repository>
    <snapshotRepository>
        <id>snapshots</id>
        <name>Nexus Snapshot Repository</name>
        <url>http://192.168.20.229:8081/nexus/content/repositories/snapshots/</url>
    </snapshotRepository>
</distributionManagement>


如果上述第2步操作,会报如下错误:

Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project Test: Failed to deploy artifacts: Could not transfer artifact com.test:Test:jar:0.0.1 from/to releases (http://192.168.20.229:8081/nexus/content/repositories/releases/): Access denied to http://192.168.20.229:8081/nexus/content/repositories/releases/com/test/Test/0.0.1/Test-0.0.1.jar. Error code 401, Unauthorized -> [Help 1]


关注下方微信公众号“Java精选”(w_z90110),回复关键字领取资料:如HadoopDubboCAS源码等等,免费领取资料视频和项目。 

涵盖:程序人生、搞笑视频、算法与数据结构、黑客技术与网络安全、前端开发、Java、Python、Redis缓存、Spring源码、各大主流框架、Web开发、大数据技术、Storm、Hadoop、MapReduce、Spark、elasticsearch、单点登录统一认证、分布式框架、集群、安卓开发、iOS开发、C/C++、.NET、Linux、Mysql、Oracle、NoSQL非关系型数据库、运维等。

评论

分享:

支付宝

微信