我有一个使用maven管理的大型Java项目。 我们正在使用Maven 3进行管理(特别是3.6.0)。
在项目中,有一个带有runtime-v5.pom.xml
的子项目。
在所说的pom
中,有一个version属性
<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依赖管理导入范围中提供版本范围?
答案 0 :(得分:0)
虽然版本范围未完全弃用,但它们不再被视为最佳实践。现代的方法是在构建之前运行适当的更新目标,以便pom中的版本号是最新的可用版本。