我有一个使用 Maven 管理的大型 Java 项目。 我们使用 Maven 3 进行管理(具体是 3.6.0)。
在项目中,有一个带有 runtime-v5.pom.xml
的 sub=project。
在所说的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 依赖管理导入范围中提供版本范围?
最佳答案
这是 Using maven dependency management import scope with version ranges 的重复项
此 Maven 问题已解决,并将在 Maven 4.0.0 中发布:https://issues.apache.org/jira/browse/MNG-4463
关于java - 无法在 Maven 依赖项管理导入范围中提供版本范围,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56222141/