maven deploy上传jar包到私服

要上传jar包的依赖:

<dependency>
    <groupId>com.sitech.ddoe</groupId>
    <artifactId>ddoe-client-all</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <classifier>jar-with-dependencies</classifier>
</dependency>

第一步:
到maven的安装路径/conf下找到setting.xml,在<servers> 下添加

<server>
    <id>CRM_BCC_RELEASE</id>
    <username>crm_bcc</username>
    <password>crm_bcc</password>
</server>
<server>
    <id>CRM_BCC_SNAPSHOTS</id>
    <username>crm_bcc</username>
    <password>crm_bcc</password>
</server>

RELEASE:存放稳定版本
SNAPSHOTS:快照,不稳定状态,可以替换成新的版本

第二步:
DOS命令行 mvn deploy

mvn deploy:deploy-file 
-DgroupId=com.sitech.ddoe 
-DartifactId=ddoe-client-all 
-Dversion=0.0.1-SNAPSHOT 
-Dclassifier=jar-with-dependencies 
-Dpackaging=jar 
-Dfile=要上传jar包的磁盘路径 
-Durl=http://私服路径/nexus/content/repositories/CRM_BCC_Snapshot/ 
-DrepositoryId=CRM_BCC_SNAPSHOTS 这里的DrepositoryId应该和setting.xml中的serverId保持一致

如果是用eclipse中执行
需要在项目的pom.xml,在<packaging> 下面配置:

<!-- 配置远程发布到私服,mvn deploy -->
<distributionManagement>
    <snapshotRepository>
        <id>CRM_BCC_SNAPSHOTS</id>
        <name>CRM_BCC Snapshot Repository</name>
        <url>私服路径/CRM_BCC_Snapshot/</url>
    </snapshotRepository>
    <repository>
        <id>CRM_BCC_RELEASE</id>
        <name>CRM_BCC Release Repository</name>
        <url>私服路径/CRM_BCC_Release/</url>
    </repository>
</distributionManagement>

然后找到mvn bulid,新建一个标签页,在Goals上填写deploy
但是更推荐DOS命令行的方式,因为可选信息比较多。

上传中遇到的错误:
1.用mvn bulid把命令行全部粘到Goals执行报错

Unknown lifecycle phase "mvn". You must specify a valid lifecycle phase or a goal in the format <plugin-prefix>:<goal> or <plugin-group-id>:<plugin-artifact-id>[:<plugin-version>]:<goal>. Available lifecycle phases are: validate, initialize, generate-sources, process-sources, generate-resources, process-resources, compile, process-classes, generate-test-sources, process-test-sources, generate-test-resources, process-test-resources, test-compile, process-test-classes, test, prepare-package, package, pre-integration-test, integration-test, post-integration-test, verify, install, deploy, pre-clean, clean, post-clean, pre-site, site, post-site, site-deploy. -> [Help 1]

错误原因是eclipse中的mvn命令会自动帮你加上mvn,如果你填的是mvn install,就会变成mvn mvn install。所以去掉mvn即可。

2.用同样的方式上传realse,报错

Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:
deploy-file (default-cli) on project standalone-pom: Failed to deploy artifacts:
 Could not transfer artifact com.sitech.ddoe:ddoe-client-all:jar:jar-with-depend
encies:0.0.1-20180605.070224-1 from/to CRM_BCC_RELEASE (path/nexus/content/repositories/CRM_BCC_Release/): Failed to transfer file: path/nexus/content/repositories/CRM_BCC_Release/com/sitech/ddoe/
ddoe-client-all/0.0.1-SNAPSHOT/ddoe-client-all-0.0.1-20180605.070224-1-jar-with-
dependencies.jar. Return code is: 400, ReasonPhrase: Bad Request. -> [Help 1]

Snapshot可以发布,但是releases却发布不了,可能是<version>1.0-SNAPSHOT</version>类似这样的,version中包含了-SNAPSHOT,所以release发布不了,也会返回400错误.

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值