java集成mongodb
In this, we will learn how to integrate MongoDB with Java and will explore the basic CRUD (Create, Retrieve, Update and Delete) operations.
在本文中,我们将学习如何将MongoDB与Java集成,并探索基本的CRUD(创建,检索,更新和删除)操作。
Download Jar, use mongo-java-driver-3.10.0.jar. Add jar to the Java build path. Now, we are ready for performing CRUD operations with MongoDB through Java.
下载Jar,使用mongo-java-driver-3.10.0.jar 。 将jar添加到Java构建路径。 现在,我们准备通过Java使用MongoDB执行CRUD操作。
Here, we are making use of MongoDB Compass - a GUI tool for MongoDB for visualizing our query output.
在这里,我们利用MongoDB Compass(MongoDB的GUI工具)来可视化查询输出。
We can connect to the DB using this user interface and then test our queries here.
我们可以使用此用户界面连接到数据库,然后在此处测试我们的查询。
Java代码与MongoDB建立连接 (Java Code to Make Connection with MongoDB)
First we must add the mongo-java-driver-3.10.0.jar file as a dependency in our Java project. So we will be adding Maven dependency like this: