java - 无法在 Maven 依赖管理导入范围内提供版本范围
问题描述
我有一个使用 maven 管理的大型 java 项目。我们使用 Maven 3 进行管理(特别是 3.6.0)。
在项目中,有一个 sub=project 带有runtime-v5.pom.xml
. 在说pom
,有一个版本属性
<properties>
<platform-v5.version>73.2.05</platform-v5.version>
</properties>
稍后在文件中使用
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.company.thing.platform</groupId>
<artifactId>platform-parent</artifactId>
<version>${platform-v5.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>com.company.release</groupId>
<artifactId>platform-v5</artifactId>
<version>${platform-v5.version}</version>
<type>resolved-pom</type>
</dependency>
</dependencies>
</dependencyManagement>
我的目标是让 maven 引入最新版本的平台,我不想每次都更新这个文件中的版本。我认为将特定版本更改为范围将允许项目始终根据给定范围拉入最新版本。
当platform-v5.version
设置为特定的现有版本时,它构建得很好,但是当将版本设置为一个范围时[73.2.05,)
,例如
[INFO] Scanning for projects...
[INFO] Downloading from all_global_universal: https://nexus.company/platform-parent/%5B73.2.05,).pom
[ERROR] Some problems were encountered while processing the POMs:
[ERROR] Non-resolvable import POM: Could not find artifact com.company.thing.platform:platform-parent:pom:[73.2.05,) in all_global_universal (https://nexus.company/content/groups/all_global_universal) @ com.company:runtime-v5:[unknown-version], path/to/runtime-v5.pom.xml, line XX, column YY
@
[ERROR] The build could not read 1 project -> [Help 1]
[ERROR]
[ERROR] The project com.company:runtime-v5:1.0.2 (path/to/runtime-v5.pom.xml) has 1 error
[ERROR] Non-resolvable import POM: Could not find artifact com.company.thing.platform:platform-parent:pom:[73.2.05,) in all_global_universal (https://nexus.company/content/groups/all_global_universal) @ com.company:runtime-v5:[unknown-version], path/to/runtime-v5.pom.xml, line XX, column YY -> [Help 2]
[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/ProjectBuildingException
[ERROR] [Help 2] http://cwiki.apache.org/confluence/display/MAVEN/UnresolvableModelException
本质上,我想知道:为什么不能在maven依赖管理导入范围内提供版本范围?
解决方案
虽然版本范围并未完全弃用,但它们不再被视为最佳实践。现代方法是在构建之前运行适当的更新目标,以便 pom 中的版本号是可用的最新版本号。
推荐阅读
- java - 如何通过任何字段从 JPA 存储库中查找?
- r - Rscipt.exe 访问被拒绝
- csv - D3 Noob:无法绑定到从 csv 文件读取的数据
- visual-c++ - VC++编译时找不到exe
- cordova - Ionic 3:直接在`file:///android_asset/www/assets/i18n`中下载和替换文件
- python - 从两个元类派生时在 __init__ 中键入错误
- r - 将布尔指标列转换为单因子列
- r - 在使用 geom_abline 创建的线之间绘制功能区
- python - 从 Pandas 数据框的 MultiIndex 中获取特定索引作为列表
- java - 多线程:持续写入共享数据结构并定期清除