简体   繁体   English

添加 MongoDB Java 驱动程序作为 Maven 依赖项的问题

[英]Issue adding MongoDB Java Driver as a Maven dependency

The title says it all really, my pom is shown below:标题说明了一切,我的 pom 如下所示:

<?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>org.example</groupId>
    <artifactId>CouncillorsApp</artifactId>
    <version>1.0-SNAPSHOT</version>

    <dependencies>
        <dependency>
            <groupId>org.mongodb</groupId>
            <artifactId>mongo-java-driver</artifactId>
            <version>3.12.6</version>
        </dependency>
    </dependencies>
</project>

The following error is given:给出以下错误:

"Dependency 'org.mongodb:mongodb-driver-sync:3.10.2' not found" “未找到依赖项 'org.mongodb:mongodb-driver-sync:3.10.2'”

I'm using Java 14.0.2 and the latest version of IntelliJ我正在使用 Java 14.0.2 和最新版本的 IntelliJ

please read installation阅读安装

you can try this你可以试试这个

<dependencies>
    <dependency>
        <groupId>org.mongodb</groupId>
        <artifactId>mongodb-driver</artifactId>
        <version>3.12.6</version>
    </dependency>
</dependencies>

So after restarting IntelliJ the above code seems to work fine.所以重启 IntelliJ 后,上面的代码似乎工作正常。 I'm unsure of where the issue was, but the dependency is being found now without any changes to the pom.我不确定问题出在哪里,但是现在可以找到依赖项,而对 pom.xml 没有任何更改。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM