原创

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),专注Java技术干货分享!让你从此路人变大神!回复关键词领取资料:如Mysql、Hadoop、Dubbo、Spring Boot等,免费领取视频教程、资料文档和项目源码。微信搜索小程序“Java精选面试题”,内涵3000+道Java面试题!

涵盖:互联网那些事、算法与数据结构、SpringMVC、Spring boot、Spring Cloud、ElasticSearch、Linux、Mysql、Oracle等

评论

分享:

支付宝

微信