英文:
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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论