java - 缺少依赖版本 - io.vertx:vertx-stack-depchain:jar 的“dependencies.dependency.version”缺失
问题描述
试图为父 pom.xml 中的不同模块指定我的 vertx 版本。我的父 pom 文件是:
<groupId>com.abc.xyc</groupId>
<artifactId>parent</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>
<name>Parent POM</name>
<modules>
...
<module>Server</module>
...
</modules>
<properties>
...
<vertx.version>3.8.2</vertx.version>
<vertx.verticle>com.abc.xyc.as4.MainVerticle</vertx.verticle>
<vertx-maven-plugin.version>1.0.22</vertx-maven-plugin.version>
<lmax.version>3.4.2</lmax.version>
...
</properties>
<dependencyManagement>
<dependencies>
...
<dependency>
<groupId>io.vertx</groupId>
<artifactId>vertx-stack-depchain</artifactId>
<version>${vertx.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>io.vertx</groupId>
<artifactId>vertx-core</artifactId>
<version>${vertx.version}</version>
</dependency>
...
</dependencies>
</dependencyManagement>
<build>
<pluginManagement>
...
<plugins>
<plugin>
<groupId>io.reactiverse</groupId>
<artifactId>vertx-maven-plugin</artifactId>
<version>${vertx-maven-plugin.version}</version>
<executions>
<execution>
<id>vmp</id>
<goals>
<goal>initialize</goal>
<goal>package</goal>
</goals>
</execution>
</executions>
<configuration>
<redeploy>true</redeploy>
</configuration>
</plugin>
</plugins>
</pluginManageme>
</build>
这是我的孩子 pom 文件
<artifactId>Server</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<parent>
<groupId>com.abc.xyc</groupId>
<artifactId>parent</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<dependencies>
...
<dependency>
<groupId>io.vertx</groupId>
<artifactId>vertx-stack-depchain</artifactId>
</dependency>
...
</dependencies>
我得到的错误是:'dependencies.dependency.version' for io.vertx:vertx-stack-depchain:jar is missing。当我在子 pom 中指定版本时,它工作正常。我的问题是为什么它没有从我的父 pom 获得版本?
解决方案
这是因为它不“管理”自己的版本,而是通过<dependencyManagement>
.
一般来说,不需要将其vertx-stack-depchain
作为依赖项导入,它应该是parent
或像你在依赖管理中所做的那样<scope>import</scope>
,然后你可以在你的子 pom 中执行以下操作:
<dependency>
<groupId>io.vertx</groupId>
<artifactId>vertx-core</artifactId>
</dependency>
如果您仍然找到导入 dep-chain 本身的充分理由,那么您需要指定版本。
推荐阅读
- assembly - DOS可执行文件中self的完整路径
- string - 将字符串的第一个字母转换为大写的快速函数?
- swift - 如何在 Firebase 中对数据进行排序?
- java - Spring Data Rest:导出非数据自定义 CrudRepository
- c# - 在运行时将数据绑定到 XAML
- javascript - 反应本地文件夹中的本地调用动态图像
- django - [DJANGO][GUNICORN] 不允许操作
- java - 验证是否存在唯一字符串的组合
- c# - 访问 ListboxItem 中的控件
- python - 为什么 2 * x * x 在 Python 3.x 中比 2 * ( x * x ) 快,对于整数?