MongoDB dependency to Java

The problem MongoDB dependency to Java

In this post, we will learn how one can add MongoDB dependency to Java. This problem is also termed as read and write from mongo. While doing this task it happens sometimes that one can’t find the required class for the same. One can try many other solutions like invalidating caches, deleting every, and recreating the projects but these options do not work well sometimes.

 

 

 

Solution

There are some points that one should keep in mind while connecting MongoDB with java. These points are as follows:

  1. One should never import libraries that are not in use. 
  2. One should prioritize using Maven if they don’t have any idea how to use Gradle. 
  3. A module becomes an automatic module if there is no module name or info. 

 

 

From the perspective of MongoDB, it is considered best to use MongoDB in JavaFX in the project that the user is building that too in a non-modular mode. The reason behind this is as follows:

  1. Due to its lack of relevant module-info, MongoDB can only be utilized as an automated module.
  2. The package definitions for the MongoDB client are divided among the several jars that the client comes in.
  • Users believe that the Java platform module system forbids configurations like this split-package definition across multiple jars.
  • Classes for the package com.mongodb are specified in mongodb-driver.jar and mongodb-driver-core.jar, respectively.

 

 

 

Also Read: post JSON with cURL

 

Share this post

Leave a Reply

Your email address will not be published. Required fields are marked *