简体   繁体   English

如何正确安装mongodb java驱动?

[英]How to properly install the mongodb java driver?

I want to create an application using MongoDB and java.我想使用 MongoDB 和 java 创建一个应用程序。 But I can't find the right files or the right documentation as to explain how to install the MongoDB java driver.但我找不到正确的文件或正确的文档来解释如何安装 MongoDB java 驱动程序。

A. I have:答:我有:

  1. Searched Google and couldn't find a proper answer用谷歌搜索,找不到合适的答案
  2. Taken a look at the MongoDB documentation (But the documentation wasn't clear enough)查看了MongoDB 文档(但文档不够清晰)

B. I have also read this question as to how you can install the MongoDB java driver but the answers there weren't clear. B. 我也读过这个关于如何安装 MongoDB java 驱动程序的问题,但答案并不清楚。

So, is there any way (literally any way) to properly install the MongoDB java driver?那么,有什么方法(字面意思是任何方法)可以正确安装 MongoDB java 驱动程序?

Well, there is no installation for the driver, you just have to add it to your dependencies in whatever tool you are using (maven, gradle, etc.) or add it to your classpath, you can find examples of how to add the dependecy for multiple tools here好吧,没有安装驱动程序,您只需将其添加到您使用的任何工具(maven、gradle 等)中的依赖项中或将其添加到您的类路径中,您可以找到如何添加依赖项的示例这里有多种工具

  • If your project is using Maven, then use the latest dependency from Maven central repository如果您的项目使用 Maven,则使用 Maven 中央存储库中的最新依赖项

  • If you are using Gradle then use:如果您使用的是 Gradle,请使用:

  dependencies {
      compile 'org.mongodb:mongodb-driver-sync:4.0.3'
  }
  • Finally, here is a quick start guide and more to get your started with using the actual driver.最后, 这里有一个快速入门指南和更多内容,让您开始使用实际的驱动程序。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM