How to insert mongodb into a java program instead of launching a daemon

Is there a way to insert mongodb into a java application instead of launching a daemon.

I downloaded the mongodb jdbc drivers and added them to the classpath.

+6
source share
1 answer

You cannot embed mongodb in a java process. This is a separate process.

You can start and stop it when your program starts / stops, creating a process. This is usually not suggested since mongodb is intended to run as a background server; if you do this, it is probably best to choose a random port to start it so that it does not affect other mongodb instances. You also need to make sure that you include the correct binaries for the platform on which the Java application is deployed, since this requires more than the JVM.

+3
source

Source: https://habr.com/ru/post/893270/


All Articles