Maven项目部署报错error: 'dependencies.dependency.version' must be a valid version but is

本文分享了一次解决Maven编译失败的经验,问题出现在从Jenkins部署到服务器的过程中。通过对Maven配置文件的检查,发现版本号设置无误。最终定位到服务器环境问题,并通过git命令发现代码处于未绑定分支状态,切换分支后问题解决。

一套资产端项目,一直使用jekins 部署,整套环境移交之后出现Maven 编译失败的问题:

‘dependencies.dependency.version’ must be a valid version but is

首先看maven的配置文件

 <mybatisplus.version>2.1.0</mybatisplus.version>
 <mybatisplus-spring-boot-starter.version>1.0.4</mybatisplus-spring-boot-starter.version>

这种问题一般不会出现

在看 本地编译是否通过,确认是服务器环境的问题。抛开Jenkins(jenkins可以理解是封装了git 和 maven 和Linux的一系列命令)

服务器环境运营mvn 命令 同样报错
运营git 命令查看本地分支信息时发现

* (detached from 801f53e)

指向了一个commit id

猜测这个提交有问题,git 命令切换成一个分支

再次运行 mvn 命令 编译通过

报错特征:
mvn clean
mvn update -U 均会报错

父工程也会报错(这点确认这套代码的配置关系失效了)

总结:

  1. maven 和 git 协作紧密
  2. 疑难问题极少出现,git 或者jenkins 的的问题(小项目不宜深入)

参考资料:https://blog.youkuaiyun.com/csfreebird/article/details/7583363
https://stackoverflow.com/questions/23690753/error-dependencies-dependency-version-must-be-a-valid-version-but-is
http://www.cnblogs.com/azhqiang/p/4942676.html

PS D:\xiaomi\prophet> mvn clean compile -Dmaven.compiler.release=19 [INFO] Scanning for projects... [WARNING] [WARNING] Some problems were encountered while building the effective model for qa-mall:prophet-api:jar:1.0-SNAPSHOT [WARNING] 'dependencyManagement.dependencies.dependency.(groupId:artifactId:type:classifier)' must be unique: com.alibaba:druid-spring-boot-starter:jar -> duplicate declaration of version 1.2.1 @ qa-mall:prophet:1.0-SNAPSHOT, D: \xiaomi\prophet\pom.xml, line 58, column 25 [WARNING] 'dependencyManagement.dependencies.dependency.(groupId:artifactId:type:classifier)' must be unique: com.alibaba.spring:spring-context-support:jar -> version 1.0.10 vs (?) @ qa-mall:prophet:1.0-SNAPSHOT, D:\xiaomi\proph et\pom.xml, line 134, column 25 [WARNING] 'dependencyManagement.dependencies.dependency.(groupId:artifactId:type:classifier)' must be unique: com.alibaba.nacos:nacos-spring-context:jar -> version 0.3.6-mone-SNAPSHOT vs (?) @ qa-mall:prophet:1.0-SNAPSHOT, D:\xi aomi\prophet\pom.xml, line 138, column 25 [WARNING] [WARNING] Some problems were encountered while building the effective model for qa-mall:prophet:pom:1.0-SNAPSHOT [WARNING] 'dependencyManagement.dependencies.dependency.(groupId:artifactId:type:classifier)' must be unique: com.alibaba:druid-spring-boot-starter:jar -> duplicate declaration of version 1.2.1 @ line 58, column 25 [WARNING] 'dependencyManagement.dependencies.dependency.(groupId:artifactId:type:classifier)' must be unique: com.alibaba.spring:spring-context-support:jar -> version 1.0.10 vs (?) @ line 134, column 25 [WARNING] 'dependencyManagement.dependencies.dependency.(groupId:artifactId:type:classifier)' must be unique: com.alibaba.nacos:nacos-spring-context:jar -> version 0.3.6-mone-SNAPSHOT vs (?) @ line 138, column 25 [WARNING] [WARNING] It is highly recommended to fix these problems because they threaten the stability of your build. [WARNING] [WARNING] For this reason, future Maven versions might no longer support building such malformed projects. [WARNING] [INFO] ------------------------------------------------------------------------ [INFO] Reactor Build Order: [INFO] [INFO] prophet [pom] [INFO] prophet-api [jar] [INFO] prophet-common [jar] [INFO] prophet-service [jar] [INFO] prophet-server [jar] [INFO] [INFO] --------------------------< qa-mall:prophet >--------------------------- [INFO] Building prophet 1.0-SNAPSHOT [1/5] [INFO] from pom.xml [INFO] --------------------------------[ pom ]--------------------------------- [INFO] ------------------------------------------------------------------------ [INFO] Reactor Summary for prophet 1.0-SNAPSHOT: [INFO] [INFO] prophet ............................................ FAILURE [ 0.007 s] [INFO] prophet-api ........................................ SKIPPED [INFO] prophet-common ..................................... SKIPPED [INFO] prophet-service .................................... SKIPPED [INFO] prophet-server ..................................... SKIPPED [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 0.373 s [INFO] Finished at: 2025-08-04T16:15:17+08:00 [INFO] ------------------------------------------------------------------------ [ERROR] Unknown lifecycle phase ".compiler.release=19". 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 lifec ycle 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-resour ces, 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-deplo y. -> [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/LifecyclePhaseNotFoundException 这又是什么错误
08-05
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值