解决 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-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中文网其它相关文章!
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号