首页 > 解决方案 > 缺少依赖版本 - 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 获得版本?

标签: javaxmlmavenpom.xmlvert.x

解决方案


这是因为它不“管理”自己的版本,而是通过<dependencyManagement>.

一般来说,不需要将其vertx-stack-depchain作为依赖项导入,它应该是parent或像你在依赖管理中所做的那样<scope>import</scope>,然后你可以在你的子 pom 中执行以下操作:

<dependency>
    <groupId>io.vertx</groupId>
    <artifactId>vertx-core</artifactId>
</dependency>

如果您仍然找到导入 dep-chain 本身的充分理由,那么您需要指定版本。


推荐阅读