Issue resolving dependencies with Maven in intellij

18 hours ago 1
ARTICLE AD BOX

I have been trying to get the demo from mongodb's website for their Java driver to compile and I managed to do so last night; however when I launched my ide after work today to get started on the actual project I have been trying to start all week I am now having the same issue with non existent packages. the changes I made last night that allowed the program to compile are still there but the error is back. I am lost and ready to give up again please help me.

import static com.mongodb.client.model.Filters.eq; import org.bson.Document; import com.mongodb.client.MongoClient; import com.mongodb.client.MongoClients; import com.mongodb.client.MongoCollection; import com.mongodb.client.MongoDatabase; public class QuickStart { public static void main( String[] args ) { // Replace the placeholder with your MongoDB deployment's connection string String uri = "mongodb+srv://Cluster91234:[email protected]/?appName=Cluster91234"; try (MongoClient mongoClient = MongoClients.create(uri)) { MongoDatabase database = mongoClient.getDatabase("sample_mflix"); MongoCollection<Document> collection = database.getCollection("movies"); Document doc = collection.find(eq("title", "Back to the Future")).first(); if (doc != null) { System.out.println(doc.toJson()); } else { System.out.println("No matching documents found."); } } } } <?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.daniel</groupId> <artifactId>StatementViewer</artifactId> <version>1.0-SNAPSHOT</version> <properties> <maven.compiler.source>25</maven.compiler.source> <maven.compiler.target>25</maven.compiler.target> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> </properties> <dependencyManagement> <dependencies> <dependency> <groupId>org.mongodb</groupId> <artifactId>mongodb-driver-bom</artifactId> <version>5.6.4</version> <type>pom</type> <scope>import</scope> </dependency> <dependency> <groupId>org.mongodb</groupId> <artifactId>mongodb-driver-sync</artifactId> </dependency> </dependencies> </dependencyManagement> </project><?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.daniel</groupId> <artifactId>StatementViewer</artifactId> <version>1.0-SNAPSHOT</version> <properties> <maven.compiler.source>25</maven.compiler.source> <maven.compiler.target>25</maven.compiler.target> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> </properties> <dependencyManagement> <dependencies> <dependency> <groupId>org.mongodb</groupId> <artifactId>mongodb-driver-bom</artifactId> <version>5.6.4</version> <type>pom</type> <scope>import</scope> </dependency> <dependency> <groupId>org.mongodb</groupId> <artifactId>mongodb-driver-sync</artifactId> </dependency> </dependencies> </dependencyManagement> </project>

and the error message

PS D:\Programming\StatementViewer> mvn compile [INFO] Scanning for projects... [INFO] [INFO] ---------------------< com.daniel:StatementViewer >--------------------- [INFO] Building StatementViewer 1.0-SNAPSHOT [INFO] from pom.xml [INFO] --------------------------------[ jar ]--------------------------------- [INFO] [INFO] --- resources:3.3.1:resources (default-resources) @ StatementViewer --- [INFO] Copying 1 resource from src\main\resources to target\classes [INFO] [INFO] --- compiler:3.13.0:compile (default-compile) @ StatementViewer --- [INFO] Recompiling the module because of changed source code. [INFO] Compiling 2 source files with javac [debug target 25] to target\classes [INFO] ------------------------------------------------------------- [ERROR] COMPILATION ERROR : [INFO] ------------------------------------------------------------- [ERROR] /D:/Programming/StatementViewer/src/main/java/QuickStart.java:[1,39] package com.mongodb.client.model does not exist [ERROR] /D:/Programming/StatementViewer/src/main/java/QuickStart.java:[1,1] static import only from classes and interfaces [ERROR] /D:/Programming/StatementViewer/src/main/java/QuickStart.java:[2,16] package org.bson does not exist [ERROR] /D:/Programming/StatementViewer/src/main/java/QuickStart.java:[3,26] package com.mongodb.client does not exist [ERROR] /D:/Programming/StatementViewer/src/main/java/QuickStart.java:[4,26] package com.mongodb.client does not exist [ERROR] /D:/Programming/StatementViewer/src/main/java/QuickStart.java:[5,26] package com.mongodb.client does not exist [ERROR] /D:/Programming/StatementViewer/src/main/java/QuickStart.java:[6,26] package com.mongodb.client does not exist [ERROR] /D:/Programming/StatementViewer/src/main/java/QuickStart.java:[11,14] cannot find symbol symbol: class MongoClient location: class QuickStart [ERROR] /D:/Programming/StatementViewer/src/main/java/QuickStart.java:[11,40] cannot find symbol symbol: variable MongoClients location: class QuickStart [ERROR] /D:/Programming/StatementViewer/src/main/java/QuickStart.java:[12,13] cannot find symbol symbol: class MongoDatabase location: class QuickStart [ERROR] /D:/Programming/StatementViewer/src/main/java/QuickStart.java:[13,13] cannot find symbol symbol: class MongoCollection location: class QuickStart [ERROR] /D:/Programming/StatementViewer/src/main/java/QuickStart.java:[13,29] cannot find symbol symbol: class Document location: class QuickStart [ERROR] /D:/Programming/StatementViewer/src/main/java/QuickStart.java:[14,13] cannot find symbol symbol: class Document location: class QuickStart [ERROR] /D:/Programming/StatementViewer/src/main/java/QuickStart.java:[14,44] cannot find symbol symbol: method eq(java.lang.String,java.lang.String) location: class QuickStart [INFO] 14 errors [INFO] ------------------------------------------------------------- [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 0.850 s [INFO] Finished at: 2026-03-20T18:04:33-07:00 [INFO] ------------------------------------------------------------------------ [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.13.0:compile (default-compile) on project StatementViewer: Compilation failure: Compilation failure: [ERROR] /D:/Programming/StatementViewer/src/main/java/QuickStart.java:[1,39] package com.mongodb.client.model does not exist [ERROR] /D:/Programming/StatementViewer/src/main/java/QuickStart.java:[1,1] static import only from classes and interfaces [ERROR] /D:/Programming/StatementViewer/src/main/java/QuickStart.java:[2,16] package org.bson does not exist [ERROR] /D:/Programming/StatementViewer/src/main/java/QuickStart.java:[3,26] package com.mongodb.client does not exist [ERROR] /D:/Programming/StatementViewer/src/main/java/QuickStart.java:[4,26] package com.mongodb.client does not exist [ERROR] /D:/Programming/StatementViewer/src/main/java/QuickStart.java:[5,26] package com.mongodb.client does not exist [ERROR] /D:/Programming/StatementViewer/src/main/java/QuickStart.java:[6,26] package com.mongodb.client does not exist [ERROR] /D:/Programming/StatementViewer/src/main/java/QuickStart.java:[11,14] cannot find symbol [ERROR] symbol: class MongoClient [ERROR] location: class QuickStart [ERROR] /D:/Programming/StatementViewer/src/main/java/QuickStart.java:[11,40] cannot find symbol [ERROR] symbol: variable MongoClients [ERROR] location: class QuickStart [ERROR] /D:/Programming/StatementViewer/src/main/java/QuickStart.java:[12,13] cannot find symbol [ERROR] symbol: class MongoDatabase [ERROR] location: class QuickStart [ERROR] /D:/Programming/StatementViewer/src/main/java/QuickStart.java:[13,13] cannot find symbol [ERROR] symbol: class MongoCollection [ERROR] location: class QuickStart [ERROR] /D:/Programming/StatementViewer/src/main/java/QuickStart.java:[13,29] cannot find symbol [ERROR] symbol: class Document [ERROR] location: class QuickStart [ERROR] /D:/Programming/StatementViewer/src/main/java/QuickStart.java:[14,13] cannot find symbol [ERROR] symbol: class Document [ERROR] location: class QuickStart [ERROR] /D:/Programming/StatementViewer/src/main/java/QuickStart.java:[14,44] cannot find symbol [ERROR] symbol: method eq(java.lang.String,java.lang.String) [ERROR] location: class QuickStart [ERROR] -> [Help 1] [ERROR] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. [ERROR] Re-run Maven using the -X switch to enable full debug logging. [ERROR] [ERROR] For more information about the errors and possible solutions, please read the following articles: [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

I believe the issue I was having yesterday was an issue with the version I had in my pom.xml.

I did try other things, but once I saw the error was back I got so dejected that I don't really remember what I tried. :)

I have checked the version again and it is still correct(to the best of my knowledge I did check the repo to make sure a new one wasn't released overnight coincidentally breaking my project somehow)

I'm hoping this is trivial to someone and they can point me in the right direction. I would like to get started on this project in this life time.

If you need any more information from me please ask

Read Entire Article