英文:
Dependency Version is missing - 'dependencies.dependency.version' for io.vertx:vertx-stack-depchain:jar is missing
问题
尝试为父 POM 中的不同模块指定 Vert.x 版本。我的父 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>
</pluginManagement>
</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 的 dependencies.dependency.version 丢失。当我在子 POM 中指定版本时,它可以正常工作。我的问题是,为什么它没有从父 POM 中获取版本?
英文:
Trying to specify my vertx version for different modules in the parent pom.
My parent pom file is:
<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>
This is my child pom file
<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>
The error I get is:'dependencies.dependency.version' for io.vertx:vertx-stack-depchain:jar is missing. When I specify the version in child pom, it works fine. My question is why isn't it getting the version from my parent pom?
答案1
得分: 2
因为它不会“管理”自己的版本,它通过<dependencyManagement>
来管理其他依赖项。
通常情况下,不需要将vertx-stack-depchain
作为依赖项导入,它应该是一个parent
,或者像您在dependency-management中使用<scope>import</scope>
那样操作,然后您可以在子项目的pom文件中执行类似以下的操作:
<dependency>
<groupId>io.vertx</groupId>
<artifactId>vertx-core</artifactId>
</dependency>
如果您仍然有充分的理由导入整个依赖链,那么您需要指定版本号。
英文:
It's because it does not "manage" its own version, it manages other dependencies via <dependencyManagement>
.
In general, there is no need to import the vertx-stack-depchain
as a depenedency, it should be a parent
or like you did in dependency-management with <scope>import</scope>
and then you can do things like the following in your child poms:
<dependency>
<groupId>io.vertx</groupId>
<artifactId>vertx-core</artifactId>
</dependency>
If you still find a good reason to import the dep-chain itself, then you need to specify the version.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论