'Dependency.Version'缺少错误,但版本在父级中管理 [英] 'dependencies.dependency.version' is missing error, but version is managed in parent

查看:34
本文介绍了'Dependency.Version'缺少错误,但版本在父级中管理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含多个模块的Maven项目。在Eclipse(Juno,带有M2E)中,它似乎编译得很好。但是,当我在其中一个模块上执行maven安装时,构建立即失败。

父POM:

  <groupId>com.sw.system4</groupId>
  <artifactId>system4-parent</artifactId>
  <version>${system4.version}</version>
  <packaging>pom</packaging>
  <name>System 4 Parent Project</name>
  <modules>
    <module>system4-data</module>
     ...others...
  </modules>
  <properties>
    <system4.version>0.0.1-SNAPSHOT</system4.version>
    <spring.version>3.2.3.RELEASE</spring.version>
    ... others...
  </properties>

  <dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-core</artifactId>
        <version>${spring.version}</version>
        <scope>runtime</scope>
      </dependency>
    ... lots of others ...
    </dependencies>
  </dependencyManagement>

子POM:

  <parent>
    <groupId>com.sw.system4</groupId>
    <artifactId>system4-parent</artifactId>
    <version>0.0.1-SNAPSHOT</version>
  </parent>
  <artifactId>system4-data</artifactId>
  <dependencies>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-core</artifactId>
        <scope>runtime</scope>
    </dependency>
    ... lots of others...
  </dependencies>

生成时,我得到以下输出:

[ERROR] The build could not read 1 project -> [Help 1]
[ERROR]
[ERROR]   The project com.sw.system4:system4-data:0.0.1-SNAPSHOT (C:workeclips
e_workspacessystemivsystem4-parentsystem4-datapom.xml) has 8 errors

[ERROR]     'dependencies.dependency.version' for org.springframework:spring-cor
e:jar is missing. @ line 16, column 16

... others omitted for clarity ...

我不明白为什么它甚至不尝试编译。我已经尝试从父对象和子对象中删除运行时作用域,但没有什么不同。请帮帮忙!

推荐答案

我觉得你可以试试:

  1. 将版本的文本值放入子级POM

    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-core</artifactId>
      <version>3.2.3.RELEASE</version>
      <scope>runtime</scope>
    </dependency>
    
  2. 清除通常位于C:Usersuser.m2的.m2缓存 储存库。我会说,当我在maven工作的时候,我经常这样做。特别是在承诺之前,这样我才能更有信心CI会参选。您不必每次都清除该文件夹,有时只需您的项目包和.cache文件夹就足够了。

  3. 将relativePath标记添加到父POM声明

    <parent>
      <groupId>com.mycompany.app</groupId>
      <artifactId>my-app</artifactId>
      <version>1</version>
     <relativePath>../parent/pom.xml</relativePath>
    </parent>
    

看起来你的POMS总共有8个错误。在添加父POM和属性之前,我会尝试运行一些基本编译。

这篇关于&#39;Dependency.Version&#39;缺少错误,但版本在父级中管理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆