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

ID:17139 / 打印

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.
上一篇: Java变量命名:多单词 应该先写“商品”还是先写“信息”?
下一篇: MySQL中 timestamp 数据同步异常:为什么同步后的数据变成了“[B@5d1c8af1”?

作者:admin @ 24资源网   2024-11-27

本站所有软件、源码、文章均有网友提供,如有侵权联系308410122@qq.com

与本文相关文章

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。