尝试为父 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>
我得到的错误是:io.vertx:vertx-stack-depchain:jar 的“dependency.dependency.version”丢失。当我在子 pom 中指定版本时,它工作正常。我的问题是为什么它没有从我的父 pom 获取版本?
最佳答案
因为它不“管理”自己的版本,而是通过 <dependencyManagement>
来管理其他依赖项.
一般情况下,不需要导入 vertx-stack-depchain
作为依赖项,它应该是 parent
或者就像您在依赖管理中使用 <scope>import</scope>
所做的那样然后你可以在你的子 poms 中执行如下操作:
<dependency>
<groupId>io.vertx</groupId>
<artifactId>vertx-core</artifactId>
</dependency>
如果您仍然找到导入 dep-chain 本身的充分理由,那么您需要指定版本。
关于java - 缺少依赖项版本 - io.vertx :vertx-stack-depchain:jar is missing 为 'dependencies.dependency.version',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63458833/