Maven parent pom variables are not resolved

前端 未结 2 1648
梦毁少年i
梦毁少年i 2021-01-06 17:16

I have the following POM structure:

./foobar-common/pom.xml ./abc-window/pom.xml ./abc-datasource/pom.xml

Both abc-window pom.xml is as follows:



        
相关标签:
2条回答
  • 2021-01-06 17:59

    The parent in abc-window is listed as:

        <parent>
                <relativePath>../foobar-common/pom.xml</relativePath>
                <groupId>hu.abc.ringcore</groupId>
                <artifactId>foobar-common</artifactId>
                <version>1.0</version>
            </parent>
    

    The parent in abc-datasource is listed as:

    <parent>
        <relativePath>../foobar-common/pom.xml</relativePath>
        <groupId>hu.ratesoft.ringcore</groupId>
        <artifactId>foobar-common</artifactId>
        <version>1.0</version>
    </parent>
    

    So, they do not have the same groupId.

    0 讨论(0)
  • 2021-01-06 18:07

    Use dependencyManagment in parent pom

    <dependencyManagement>
      <dependencies>
        <dependency>
           <groupId>junit</groupId>
           <artifactId>junit</artifactId>
           <version>${junit.version}</version>
        </dependency>
        <dependency>
           <groupId>org.apache.commons</groupId>
           <artifactId>commons-lang3</artifactId>
           <version>${commons-lang3.version}</version>
        </dependency>
        </dependencies>
      </dependencyManagement>  
    

    add all versions in parent pom, and use dependencies without version in children

    EDIT

    /pom.xml                 <-parent pom
    /abc-window/pom.xml     <-child module  
    /abc-datasource/pom.xml <-child module  
    

    and parent pom should contains

    <project  
    ...  
       <properties>   
        ... 
       </properties>  
       <modules>  
          <module>abc-datasource</module>
          <module>abc-window</module>  
       </modules>   
       <build>
          <pluginManagment>   
           ...
          </pluginManagment>
       </build>
       <dependencyManagment>
        ...  
       </dependencyManagment>  
    </project>
    
    0 讨论(0)
提交回复
热议问题