首页 > Java > java教程 > 正文

Maven 多项目打包中,${reversion} 变量未替换,如何解决?

心靈之曲
发布: 2024-11-06 13:33:01
原创
525人浏览过

maven 多项目打包中,${reversion} 变量未替换,如何解决?

解决 maven 多项目打包中 ${reversion} 未替换问题

在使用 maven 管理多项目时,遇到如下打包错误:

failed to read artifact descriptor for com.example:c2:jar:1.0.0-snapshot: failure to find com.example:packagetest:pom:${reversion} in <a href="http://xxxx/repository/maven-public/" target="_blank">http://xxxx/repository/maven-public/</a> was cached in the local repository, resolution will not be reattempted until the update interval of nexus-repo has elapsed or updates are forced -> [help 1]
登录后复制

原因是父项目中使用 ${reversion} 作为版本变量,子项目在打包时无法在本地仓库中找到匹配的父项目 pom 文件。

解决方法是:

  • 在父项目中直接设置版本号

例如:

<project>
  <groupid>com.example</groupid>
  <artifactid>packagetest</artifactid>
  <version>1.0.0-snapshot</version>
</project>
登录后复制
  • 使用 maven 插件批量更新版本号

可以使用 maven-release-plugin 插件批量更新子项目的父项目版本号:

<plugin>
  <groupid>org.apache.maven.plugins</groupid>
  <artifactid>maven-release-plugin</artifactid>
  <version>3.1.2</version>
  <configuration>
    <developmentversion>1.0.0-snapshot</developmentversion>
  </configuration>
</plugin>
登录后复制

maven 官方对于 relativepath 的解释:

The relative path of the parent pom.xml file within the check out. If not specified, it defaults to ../pom.xml. Maven looks for the parent POM first in this location on the filesystem, then the local repository, and lastly in the remote repo. relativePath allows you to select a different location, for example when your structure is flat, or deeper without an intermediate parent POM. However, the group ID, artifact ID and version are still required, and must match the file in the location given or it will revert to the repository for the POM. This feature is only for enhancing the development in a local checkout of that project. Set the value to an empty string in case you want to disable the feature and always resolve the parent POM from the repositories.

Default value is: ../pom.xml.
登录后复制

以上就是Maven 多项目打包中,${reversion} 变量未替换,如何解决?的详细内容,更多请关注php中文网其它相关文章!

最佳 Windows 性能的顶级免费优化软件
最佳 Windows 性能的顶级免费优化软件

每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。

下载
相关标签:
来源:php中文网
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
最新问题
开源免费商场系统广告
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 意见反馈 讲师合作 广告合作 最新更新
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习
PHP中文网抖音号
发现有趣的

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号