我正在尝试在我的 Java 项目中使用 MongoDB。
将我的项目导出到文件后,我收到 MongoClient 的无类定义错误。
导出时我没有收到任何错误。
我使用 Maven 导入不同的依赖项,所有 jar 都被正确导出
import com.mongodb.client.MongoClient;
import com.mongodb.client.MongoClients;
public class MongoDB {
private static MongoClient client;
public static void init() {
try {
client = MongoClients.create("mongodb://localhost:27017/xenoncraft");
System.out.println("[XenonSuite] Successfully connected to MongoDB");
} catch(Exception e) {
System.out.println("[XenonSuite] Following errors were catched while connecting to MongoDB");
e.printStackTrace();
}
}
守着星空守着你
慕运维8079593
相关分类