Working with MongoDB using Java Core isn't all that difficult either. Create a new Gradle project and install the mongodb driver and mongodb bson packages, as follows:
apply plugin: 'java-library' repositories { jcenter() } dependencies { implementation 'org.mongodb:mongo-java-driver:3.9.0' implementation 'org.mongodb:bson:3.0.0’ }
Next, create a Plain Old Java Object (POJO) to represent our JSON document:
package com.packtpub.azure// [...]public class Person { @BsonId private ObjectId Id; // [...]public ObjectId getId() { return id; }public Person setId(ObjectId id) { this.id = id; return this; }// [...]}
Now, we can write the application:
public com.packtpub.azure; // [...] public class AzureMongoDBConsoleApp ...