将 Mongodb 驱动程序升级到 4.7.0 在 Spring Boot 2.7.15 中不起作用

问题描述 投票:0回答:1

我正在尝试将 MongoDB 驱动程序从 4.6.1 升级到 4.7.0,但驱动程序未升级到 MongoDb 驱动程序 4.7.0。已尝试使用 springboot 2.7.15 版本,但驱动程序未升级到 MongoDB 驱动程序 4.7.0。 Maven pom.xml 如下所示。我想使用内置版本的 mongodb 驱动程序 4.7.0,但版本升级没有发生。谁能帮我如何升级 mongoDB 驱动程序 4.7.0。感谢任何帮助。

<?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.agcs.cids</groupId>
    <artifactId>SampleService</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>jar</packaging>

    <name>SampleService</name>
    <description>Project for SampleService Service</description>

    <properties>
        <java.version>1.8</java.version>
        <springboot.version>2.7.15</springboot.version>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <surefire-plugin.version>2.22.0</surefire-plugin.version>
    </properties>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-parent</artifactId>
                <version>${springboot.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-mongodb</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-rest</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-validation</artifactId>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.google.code.gson</groupId>
            <artifactId>gson</artifactId>
            <version>2.8.2</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-security</artifactId>
        </dependency>



    </dependencies>

    <repositories>
        <repository>
            <id>spring-milestone</id>
            <name>Spring Maven MILESTONE Repository</name>
            <url>https://repo.spring.io/libs-milestone</url>
        </repository>
    </repositories>

    <build>
        <plugins>
            <plugin>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.22.2</version>
                <configuration>
                    <systemProperties>
                        <java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
                    </systemProperties>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <version>${springboot.version}</version>
                <configuration>
                    <arguments>
                        <source>1.8</source>
                        <target>1.8</target>
                        <uberJar>true</uberJar>
                    </arguments>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>repackage</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

    <distributionManagement>
        <repository>
            <id>toolchain-nexus</id>
            <url>${nexus.release.url}</url>
        </repository>

        <snapshotRepository>
            <id>toolchain-nexus</id>
            <url>${nexus.snapshot.url}</url>
        </snapshotRepository>
    </distributionManagement>
</project>
java mongodb spring-boot spring-data-mongodb
1个回答
0
投票

添加您要使用的特定驱动程序版本的依赖项。

<dependency>
    <groupId>org.mongodb</groupId>
    <artifactId>mongodb-driver-sync</artifactId>
    <version>4.7.0</version>
</dependency>

Maven 将遵循此版本,而不是 Spring 提供的临时版本。

© www.soinside.com 2019 - 2024. All rights reserved.