Maven spring-data-mongodb showing lower version of mongodb-driver-core

Viewed 16

I have a project that uses spring-data-mongodb. I define the following dependency on my pom.xml:

<dependency>
  <groupId>org.springframework.data</groupId>
  <artifactId>spring-data-mongodb</artifactId>
</dependency>

The version is managed by the parent project and the version I define is 3.3.7. However when I run mvn dependency:tree on the project I get the following entry:

\- org.springframework.data:spring-data-mongodb:jar:3.3.7:compile
[INFO]    +- org.springframework:spring-tx:jar:5.1.10.RELEASE:compile
[INFO]    +- org.springframework:spring-context:jar:5.1.10.RELEASE:compile
[INFO]    |  \- org.springframework:spring-aop:jar:5.1.10.RELEASE:compile
[INFO]    +- org.springframework:spring-beans:jar:5.1.10.RELEASE:compile
[INFO]    +- org.springframework:spring-expression:jar:5.1.10.RELEASE:compile
[INFO]    +- org.springframework.data:spring-data-commons:jar:2.1.11.RELEASE:compile
[INFO]    +- org.mongodb:mongodb-driver-core:jar:3.8.2:compile
[INFO]    |  \- org.mongodb:bson:jar:3.8.2:compile

The problem here is that the version of mongodb-driver-core (one line before the end of the output above) is much lower than the one defined in the specific version of spring-data-mongodb.

I cannot understand why this is happening... I need to use the lates version of mongodb-driver-core but for some reason I am getting a lower version. My projects pom.xml is listed below (only thing missing is a custom dependency which I don't want to disclose)

<dependencies>
    <dependency>
        <groupId>org.projectlombok</groupId>
        <artifactId>lombok</artifactId>
    </dependency>
    <dependency>
        <groupId>commons-lang</groupId>
        <artifactId>commons-lang</artifactId>
        <version>2.4</version>
    </dependency>
    <dependency>
        <groupId>com.fasterxml.jackson.dataformat</groupId>
        <artifactId>jackson-dataformat-xml</artifactId>
        <version>2.11.2</version>
    </dependency>

    <dependency>
        <groupId>javax.annotation</groupId>
        <artifactId>javax.annotation-api</artifactId>
        <version>1.3.2</version>
    </dependency>

    <dependency>
        <groupId>com.sun.xml.bind</groupId>
        <artifactId>jaxb-impl</artifactId>
    </dependency>

    <!-- Mongo dependencies -->
    <dependency>
        <groupId>org.springframework.data</groupId>
        <artifactId>spring-data-mongodb</artifactId>
    </dependency>

    <dependency>
        <groupId>org.springframework.data</groupId>
        <artifactId>spring-data-releasetrain</artifactId>
        <version>Lovelace-SR11</version>
        <type>pom</type>
        <scope>import</scope>
    </dependency>
</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-resources-plugin</artifactId>
            <version>3.1.0</version>
            <configuration>
                <delimiters>
                    <delimiter>@</delimiter>
                </delimiters>
                <useDefaultDelimiters>false</useDefaultDelimiters>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.8.1</version>
            <configuration>
                <release>${java.version}</release>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-source-plugin</artifactId>
            <version>3.1.0</version>
            <executions>
                <execution>
                    <id>attach-sources</id>
                    <goals>
                        <goal>jar</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>

        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>buildnumber-maven-plugin</artifactId>
            <version>1.4</version>
            <executions>
                <execution>
                    <phase>validate</phase>
                    <goals>
                        <goal>create</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <doCheck>false</doCheck>
                <doUpdate>false</doUpdate>
                <revisionOnScmFailure>true</revisionOnScmFailure>
                <shortRevisionLength>7</shortRevisionLength>
            </configuration>
        </plugin>
    </plugins>
</build>

Adding portion of the parent pom.xml as well

  <properties>
         <java.version>11</java.version>
        <jaxb.version>2.3.3</jaxb.version>
        <spring-boot.version>2.1.9.RELEASE</spring-boot.version>
        <spring.mongodb.version>3.3.7</spring.mongodb.version>
        <spring-cloud.version>Greenwich.SR3</spring-cloud.version>
        <spring-cloud-stream.version>Germantown.RELEASE</spring-cloud-stream.version>
        <spring-cloud-app-starters.version>2.1.2.RELEASE</spring-cloud-app-starters.version>
   </properties>
   <dependencyManagement>
            <dependencies>
                <!-- Spring Boot -->
                <dependency>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-dependencies</artifactId>
                    <version>${spring-boot.version}</version>
                    <type>pom</type>
                    <scope>import</scope>
                </dependency>
    
                <dependency>
                    <groupId>org.springframework.data</groupId>
                    <artifactId>spring-data-mongodb</artifactId>
                    <version>${spring.mongodb.version}</version>
                </dependency>
    
                <dependency>
                    <groupId>com.sun.xml.bind</groupId>
                    <artifactId>jaxb-impl</artifactId>
                    <version>${jaxb.version}</version>
                </dependency>
    </dependencies>
</dependencyManagement>

Any help would be appreciated.

1 Answers

Turns out that the spring-boot version defined in my parent pom.xml is the one that affects the spring-data-mongodb version. By raising the spring-boot version I solved the problem... thank you M. Deinum for the comment.

Related