javamavenparent-pomapache-dubbo

why child pom create a new version?


  1. Parent pom code

    
        <modelVersion>4.0.0</modelVersion>
        <groupId>com.example</groupId>
        <artifactId>SpringCloudDemo</artifactId>
        <version>0.0.1-SNAPSHOT</version>
        <name>SpringCloudDemo</name>
        <description>SpringCloudDemo</description>
        <packaging>pom</packaging>
    
        <dependencyManagement>
            <dependencies>
    
                <dependency>
                    <groupId>org.apache.dubbo</groupId>
                    <artifactId>dubbo-spring-boot-starter</artifactId>
                    <version>${spring-boot-dubbo.version}</version>
                    <type>pom</type>
                    <scope>import</scope>
                </dependency>
                <dependency>
                    <groupId>org.apache.dubbo</groupId>
                    <artifactId>dubbo</artifactId>
                    <version>${spring-boot-dubbo.version}</version>
                    <type>pom</type>
                    <scope>import</scope>
                </dependency>
    
                <dependency>
                    <groupId>org.apache.dubbo</groupId>
                    <artifactId>dubbo-registry-nacos</artifactId>
                    <version>${spring-boot-dubbo-nacos.version}</version>
                    <type>pom</type>
                    <scope>import</scope>
                </dependency>
    
    
            </dependencies>
        </dependencyManagement>
    
    
  2. in child pom ,child extends parent pom In Child POM

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

    <dependencies>

        <dependency>
            <groupId>org.apache.dubbo</groupId>
            <artifactId>dubbo-spring-boot-starter</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.dubbo</groupId>
            <artifactId>dubbo</artifactId>
        </dependency>
        <!-- Nacos依赖 -->
        <dependency>
            <groupId>org.apache.dubbo</groupId>
            <artifactId>dubbo-registry-nacos</artifactId>
            <version>3.0.1</version>
        </dependency>


    </dependencies>
  1. But my child pom download 2.7.4.1 version,no use Parent Pom 3.1.9 Version dubbo,like picture
  2. I have one questions:

I want use 3.1.9 Version Dubbo ,But In Child Pom download 2.7.4.1 Version Dubbo?what happening?


Solution

  • Perhaps the problem could be in defining dependencies in the <dependentManagement/> section in the parent pom. For example:

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.apache.dubbo</groupId>
                <artifactId>dubbo-spring-boot-starter</artifactId>
                <version>${spring-boot-dubbo.version}</version>
                <type>pom</type> <!-- wrong -->
                <scope>import</scope> <!-- wrong -->
            </dependency>
        </dependencies>
    </dependencyManagement>
    

    The <type/> and </scope> are incorrect, beacuse the dubbo-spring-boot-starter dependency isn't of type pom and you didn't should to define the scope as import.

    According to official docs, the import scope is only relevant for depepndencies with type pom:

    This scope is only supported on a dependency of type pom in the <dependencyManagement> section. It indicates the dependency is to be replaced with the effective list of dependencies in the specified POM's <dependencyManagement> section. Since they are replaced, dependencies with a scope of import do not actually participate in limiting the transitivity of a dependency.

    Try to remove the type and scope from all dependencies in the <dependentManagement/> section in the parent pom.

    It is just a guess.