Sean E.
Sean E.

Reputation: 73

Issue adding MongoDB Java Driver as a Maven dependency

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

Upvotes: 1

Views: 8561

Answers (4)

Roy Huang
Roy Huang

Reputation: 41

On the right side of the IDEA, click Maven

enter image description here

Click blue circled button.

enter image description here

Then dependencies should throw no more errors.

Upvotes: 1

kriti arora
kriti arora

Reputation: 119

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.

Upvotes: 0

Sean E.
Sean E.

Reputation: 73

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.

Upvotes: 1

dinobi
dinobi

Reputation: 560

please read installation

you can try this

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

Upvotes: 1

Related Questions