#How to use MongoDB in java?
28 messages · Page 1 of 1 (latest)
⌛ This post has been reserved for your question.
Hey @hexed eagle! Please use
/closeor theClose Postbutton above when you're finished. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.
TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.
- Set up MongoDB somewhere
- Add MongoDB driver to your project as a dependency
- Create MongoDB client in your application
- Connect to MongoDB
- Issue commands you want with MongoDB client
This is a really easy to google question with tons of examples out there. I suggest you to search for a tutorial and just follow along either from youtube or blog whatever you prefer more and get back with a more concrete question if something does not work the way you expect.
how to add as dependency (step 2)
i use intellij's build
here's how to add module dependencies in intellij without a build system: https://www.jetbrains.com/help/idea/working-with-module-dependencies.html#remove-dependency but i strongly recommend using a dependency management system like gradle or maven to do this
it doesnt have mongodb
Well yeah you're supposed to add MongoDB there
imp sent the wrong like by mistake, but it's quite literally above the remove section
where should i get the depend3encies of mongo
They should have a download link somewhere
Like imp I do recommend using Maven or Gradle instead of using Artifacts
but this jar is likely to have other dependencies so it might not work if you just add that jar
(hence my recommendation to use a depmgmt system)
yeah it has dependencies on slf4j (optional), bson and mongodb-driver-core:
Yeah