代码之家  ›  专栏  ›  技术社区  ›  bbarker

如何解决父pom依赖性问题:未能读取项目描述符;找不到项目?

  •  1
  • bbarker  · 技术社区  · 7 年前

    https://search.maven.org/search?q=ced2ar3-rdb

    这三个是 same project

    我现在正尝试使用ced2arrdb和ced2arrdb测试作为依赖项来构建一个新项目,但我不想在代码中的何处引用父pom文件(ced2ar3rdb parent;我实际上不想使用它,也不认为我需要它)。但是,当我尝试构建使用ced2ar rdb作为依赖项的项目时,出现以下错误:

    [ERROR] Failed to execute goal on project ced2ar3-services-core: Could not resolve dependencies for project edu.cornell.
    ncrn.ced2ar:ced2ar3-services-core:jar:0.0.0: Failed to collect dependencies at edu.cornell.ncrn.ced2ar:ced2ar3-rdb:jar:0
    .0.1: Failed to read artifact descriptor for edu.cornell.ncrn.ced2ar:ced2ar3-rdb:jar:0.0.1: Could not find artifact edu.
    cornell.ncrn.ced2ar:ced2ar3-rdb-parent:pom:${ced2ar.version} in central (https://repo.maven.apache.org/maven2) -> [Help   
    

    这个问题和我 <version>${ced2ar.version}</version> 在父pom中,即使 ${ced2ar.version} <properties> 再往下查?

    1 回复  |  直到 7 年前
        1
  •  12
  •   davidxxx    7 年前

    这个问题和我 ${2塞得配置总成版本}在下一步中正确定义

    不,问题来自您声明子模块的方式。
    下面是rdb模块的摘录 pom

    <project xmlns="http://maven.apache.org/POM/4.0.0"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
        <parent>
            <artifactId>ced2ar3-rdb-parent</artifactId>
            <groupId>edu.cornell.ncrn.ced2ar</groupId>
            <version>${ced2ar.version}</version>
        </parent>
        <modelVersion>4.0.0</modelVersion>
    
        <artifactId>ced2ar3-rdb</artifactId>
    
    </project>
    

    这个 ${ced2ar.version}

    来解决你的问题 you could use the revision standard property flatten-maven-plugin 这将帮助您在父级和子级之间设置唯一的版本。

    你的反应堆聚甲醛看起来像:

    <project>
      <modelVersion>4.0.0</modelVersion>     
      <groupId>my-group</groupId>
      <artifactId>my-parent</artifactId>
      <version>${revision}</version>
      ...
      <properties>
        <revision>1.0.0</revision>
      </properties>
      <modules>
        <module>rdb</module>
        <module>rdb-tests</module>
        ..
      </modules>
    
     <build>
      <plugins>
        <plugin>
          <groupId>org.codehaus.mojo</groupId>
          <artifactId>flatten-maven-plugin</artifactId>
          <version>1.0.0</version>
          <configuration>
            <updatePomFile>true</updatePomFile>
          </configuration>
          <executions>
            <execution>
              <id>flatten</id>
              <phase>process-resources</phase>
              <goals>
                <goal>flatten</goal>
              </goals>
            </execution>
            <execution>
              <id>flatten.clean</id>
              <phase>clean</phase>
              <goals>
                <goal>clean</goal>
              </goals>
            </execution>
          </executions>
        </plugin>
      </plugins>
      </build>
    </project>
    

    <project>
      <parent>
        <groupId>my-group</groupId>
        <artifactId>my-parent</artifactId>
        <version>${revision}</version>
      </parent>
    
      <artifactId>rdb</artifactId>
       ...
    </project>
    

    关于您的评论:

    我得到一个无效的POM错误:“Project name missing,Project 信息缺失”。事实上,在检查了

    预计为 flattened plugin strips some metadata of the original POM

    扁平POM是原始POM的简化版本,具有 专注于只包含使用它的重要信息。 因此,仅用于维护的信息 . 启动 从这里我们指定如何从

    但是您可以通过添加不希望在 pomElements
    例如:

    <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>flatten-maven-plugin</artifactId>
        <version>1.0.0</version>
        <configuration>
            <updatePomFile>true</updatePomFile>
            <pomElements>
                <name/>
                <description/>
                <developers/>
                <contributors/>
                <url/>
                <scm/>
            </pomElements>                  
        </configuration>
        <executions>
            <execution>
                <id>flatten</id>
                <phase>process-resources</phase>
                <goals>
                    <goal>flatten</goal>
                </goals>
            </execution>
            <execution>
                <id>flatten.clean</id>
                <phase>clean</phase>
                <goals>
                    <goal>clean</goal>
                </goals>
            </execution>
        </executions>
    </plugin>