问题:添加MongoDB Java驱动作为Maven依赖。

huangapple go评论60阅读模式
英文:

Issue adding MongoDB Java Driver as a Maven dependency

问题

以下是翻译好的部分:

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

英文:

The title says it all really, my pom is shown below:

<?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"

I'm using Java 14.0.2 and the latest version of IntelliJ

答案1

得分: 1

阅读安装指南

你可以尝试以下代码:

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

please read installation

you can try this

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

答案2

得分: 1

在重启 IntelliJ 后,上面的代码似乎可以正常工作。我不确定问题出在哪里,但是依赖项现在可以被找到,而且 pom 文件没有进行任何更改。

英文:

So after restarting IntelliJ the above code seems to work fine. I'm unsure of where the issue was, but the dependency is being found now without any changes to the pom.

答案3

得分: 0

请确保如果您正在为不同的环境工作VPN,请确保它已连接到您的数据环境。这发生在我的情况中。

英文:

If you are working on VPN for different environments, please make sure it is connected to the environment of your data. This happened with me.

huangapple
  • 本文由 发表于 2020年7月30日 07:43:35
  • 转载请务必保留本文链接:https://go.coder-hub.com/63164092.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定