Maven - 札记 - [ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy

本文介绍了当执行Maven deploy生命周期时遇到`repository element was not specified`错误的原因及解决方案。该问题源于Maven deploy插件2.7和2.8版本之间的配置差异。解决方案包括在pom.xml中指定仓库信息或更新deploy插件到2.8+版本以使用settings.xml配置。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >


Centos - 目录


Maven - 札记 - Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy "default-deploy"on project xxx: Deployment failed: repository element was not specified in the POM inside distributionManagement element or in -DaltDeploymentRepository=id::layout::url parameter


一、问题描述


1. 现象

执行 Maven deploy 生命周期提示以下信息:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project xxx: Deployment failed: repository element was not specified in the POM inside distributionManagement element or in -DaltDeploymentRepository=id::layout::url parameter -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

2. 原因

deploy 插件 2.7 版本和 2.8 版本有配置上的差异。

  • 2.7 版本需要在项目的 pom.xml 文件中配置上传的仓库信息(以下内容仅供参考,请根据自己的仓库信息自行调整
    <distributionManagement>
    	<repository>
    		<id>rdc-release</id>
    		<url>https://packages.aliyun.com/maven/repository/xxx-release-xxx/</url>
    	</repository>
    	<snapshotRepository>
    		<id>rdc-snapshot</id>
    		<url>https://packages.aliyun.com/maven/repository/xxx-snapshot-xxx/</url>
    	</snapshotRepository>
    </distributionManagement>
    
  • 2.8 版本会使用 setting.xml 中的配置(以下内容仅供参考,请根据自己的仓库信息自行调整
    <profiles>
    	<profile>
    		<id>rdc</id>
    		<properties>
    			<altReleaseDeploymentRepository>
    				rdc-releases::default::https://packages.aliyun.com/maven/repository/xxx-release-xxx/
    			</altReleaseDeploymentRepository>
    			<altSnapshotDeploymentRepository>
    				rdc-snapshots::default::https://packages.aliyun.com/maven/repository/xxx-snapshot-xxx/
    			</altSnapshotDeploymentRepository>
    		</properties>
    	</profile>
    </profiles>
    

二、解决方案


根据自己情况选择对应解决方案

  • 不想在 pom.xml 配置仓库信息(解决方案:在 pom.xml 中指定 deploy 版本为 2.8+)
    <plugin>
    	<groupId>org.apache.maven.plugins</groupId>
    	<artifactId>maven-deploy-plugin</artifactId>
    	<version>2.8</version>
    </plugin>
    
  • 不想配置 deploy 版本信息,想使用 deploy 默认版本(解决方案:在 pom.xml 配置仓库信息)
    <distributionManagement>
    	<repository>
    		<id>rdc-release</id>
    		<url>https://packages.aliyun.com/maven/repository/xxx-release-xxx/</url>
    	</repository>
    	<snapshotRepository>
    		<id>rdc-snapshot</id>
    		<url>https://packages.aliyun.com/maven/repository/xxx-snapshot-xxx/</url>
    	</snapshotRepository>
    </distributionManagement>
    
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

qumy97

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值