Dependency Version is missing – 'dependencies.dependency.version' for io.vertx:vertx-stack-depchain:jar is missing

huangapple go评论70阅读模式
英文:

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:

&lt;groupId&gt;com.abc.xyc&lt;/groupId&gt;
&lt;artifactId&gt;parent&lt;/artifactId&gt;
&lt;version&gt;1.0-SNAPSHOT&lt;/version&gt;
&lt;packaging&gt;pom&lt;/packaging&gt;
&lt;name&gt;Parent POM&lt;/name&gt;

&lt;modules&gt;
    ...
    &lt;module&gt;Server&lt;/module&gt;
    ...
&lt;/modules&gt;

&lt;properties&gt;
    ...
    &lt;vertx.version&gt;3.8.2&lt;/vertx.version&gt;
    &lt;vertx.verticle&gt;com.abc.xyc.as4.MainVerticle&lt;/vertx.verticle&gt;
    &lt;vertx-maven-plugin.version&gt;1.0.22&lt;/vertx-maven-plugin.version&gt;
    &lt;lmax.version&gt;3.4.2&lt;/lmax.version&gt;
    ...
&lt;/properties&gt;

&lt;dependencyManagement&gt;
    &lt;dependencies&gt;
        ...
        &lt;dependency&gt;
            &lt;groupId&gt;io.vertx&lt;/groupId&gt;
            &lt;artifactId&gt;vertx-stack-depchain&lt;/artifactId&gt;
            &lt;version&gt;${vertx.version}&lt;/version&gt;
            &lt;type&gt;pom&lt;/type&gt;
            &lt;scope&gt;import&lt;/scope&gt;
        &lt;/dependency&gt;
        &lt;dependency&gt;
            &lt;groupId&gt;io.vertx&lt;/groupId&gt;
            &lt;artifactId&gt;vertx-core&lt;/artifactId&gt;
            &lt;version&gt;${vertx.version}&lt;/version&gt;
        &lt;/dependency&gt;
        ...
    &lt;/dependencies&gt;
&lt;/dependencyManagement&gt;

&lt;build&gt;
        &lt;pluginManagement&gt;
            ...
            &lt;plugins&gt;
                &lt;plugin&gt;
                    &lt;groupId&gt;io.reactiverse&lt;/groupId&gt;
                    &lt;artifactId&gt;vertx-maven-plugin&lt;/artifactId&gt;
                    &lt;version&gt;${vertx-maven-plugin.version}&lt;/version&gt;
                    &lt;executions&gt;
                        &lt;execution&gt;
                            &lt;id&gt;vmp&lt;/id&gt;
                            &lt;goals&gt;
                                &lt;goal&gt;initialize&lt;/goal&gt;
                                &lt;goal&gt;package&lt;/goal&gt;
                            &lt;/goals&gt;
                        &lt;/execution&gt;
                    &lt;/executions&gt;
                    &lt;configuration&gt;
                        &lt;redeploy&gt;true&lt;/redeploy&gt;
                    &lt;/configuration&gt;
                &lt;/plugin&gt;
            &lt;/plugins&gt;
        &lt;/pluginManageme&gt;
&lt;/build&gt;

This is my child pom file

&lt;artifactId&gt;Server&lt;/artifactId&gt;
&lt;version&gt;1.0-SNAPSHOT&lt;/version&gt;
&lt;packaging&gt;jar&lt;/packaging&gt;

&lt;parent&gt;
    &lt;groupId&gt;com.abc.xyc&lt;/groupId&gt;
    &lt;artifactId&gt;parent&lt;/artifactId&gt;
    &lt;version&gt;1.0-SNAPSHOT&lt;/version&gt;
&lt;/parent&gt;

&lt;dependencies&gt;
    ...
    &lt;dependency&gt;
        &lt;groupId&gt;io.vertx&lt;/groupId&gt;
        &lt;artifactId&gt;vertx-stack-depchain&lt;/artifactId&gt;
    &lt;/dependency&gt;
    ... 
&lt;/dependencies&gt;

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 &lt;dependencyManagement&gt;.

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 &lt;scope&gt;import&lt;/scope&gt; and then you can do things like the following in your child poms:

&lt;dependency&gt;
    &lt;groupId&gt;io.vertx&lt;/groupId&gt;
    &lt;artifactId&gt;vertx-core&lt;/artifactId&gt;
&lt;/dependency&gt;

If you still find a good reason to import the dep-chain itself, then you need to specify the version.

huangapple
  • 本文由 发表于 2020年8月18日 05:22:44
  • 转载请务必保留本文链接:https://go.coder-hub.com/63458833.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定