'parent.relativePath' points at my com.mycompany:MyProject instead of org.apache:apache - Why?

前端 未结 5 1457
情书的邮戳
情书的邮戳 2020-12-23 02:53

What is true is that Solr project directory is inside MyProject parent directory (but there\'s no module or any maven relationship between the 2, just FS convenience). Do I

相关标签:
5条回答
  • 2020-12-23 03:00

    I have a fringe case. A fat finger case on my part.

    My pom parent had this:

    <?xml version="1.0" encoding="UTF-8"?>
    <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">
        <modelVersion>4.0.0</modelVersion>
        <groupId>com.mygroup </groupId>
        <artifactId>pom-parent</artifactId>
        <version>0.0.1-SNAPSHOT</version>
        <packaging>pom</packaging>
        <name>pom-parent</name>
    

    and my (child) pom

    <parent>
        <groupId>com.mygroup</groupId>
        <artifactId>pom-parent</artifactId>
        <version>0.0.1-SNAPSHOT</version>
        <relativePath>../pom-parent/pom.xml</relativePath>
    </parent>  
    

    My group id in my parent had a fat finger space at the end of the name. "com.mygroup " instead of the correct "com.mygroup".

    Because of this fat finger mistake........the "groupId" names did not match....and I got the error.

    Aka, check for fat finger mistakes before you go to too many extremes to resolve.

    error I got for internet-searching

    "Project build error: 'parent.relativePath' of POM" "points at" "please verify your project structure"

    0 讨论(0)
  • 2020-12-23 03:09

    I think you have missed out the <relativePath> tag in the question. I'm saying that because, without it This error will not arise. That being said,

    The line you will have to concentrate is the below warning statement.

    'parent.relativePath' points at com.mycompany:MyProject instead of org.apache:apache

    It clearly says that the relative path of tag on your module points to a pom file which has different artifactId compared to what is specified

    This is because there is a mismatch between the artifactId of your parent/pom.xml and the artifactId you have mentioned in the <parent> tag of module/pom.xml. To avoid the warning change the <parent> in your module/pom.xml as shown below.

      <parent>
        <groupId>com.mycompany</groupId>
        <artifactId>MyProject</artifactId>
        <version>8</version>
        <relativePath>path-to-your-parent-pom.xml</relativePath>
      </parent>
    
    0 讨论(0)
  • 2020-12-23 03:12

    That message might be caused by a pom.xml in the parent directory relative to your current project. The pom in the parent directory does not match the project.parent config of the current pom.

    0 讨论(0)
  • 2020-12-23 03:17

    either ignore the warning, move the sources out of the unrelated parent or enter the correct value of to the element. The problem is caused by the default value for relativePath which is ../pom.xml and that default value gets injected in your effective pom, triggering the warning.

    0 讨论(0)
  • 2020-12-23 03:23

    Add an empty <relativePath> to <parent> so that it resolves the parent pom from the repositories.

      <parent>
        <groupId>org.apache</groupId>
        <artifactId>apache</artifactId>
        <version>8</version>
        <relativePath></relativePath>
      </parent>
    

    Here is the relevant doc.

    This feature is only for enhancing the development in a local checkout of that project. Set the value to an empty string in case you want to disable the feature and always resolve the parent POM from the repositories.
    Default value is: ../pom.xml.

    0 讨论(0)
提交回复
热议问题