在執行下列通過NetBeans的NoClassDefFoundError的同時建立的MongoDB連接代碼
Exception in thread "main" java.lang.NoClassDefFoundError: com/mongodb/connection/BufferProvider at Mongoconnect.main(Mongoconnect.java:8) Caused by: java.lang.ClassNotFoundException: com.mongodb.connection.BufferProvider at java.net.URLClassLoader.findClass(URLClassLoader.java:381) at java.lang.ClassLoader.loadClass(ClassLoader.java:424) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331) at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ... 1 more`
import com.mongodb.MongoClient;
import com.mongodb.MongoClientURI;
import com.mongodb.client.MongoDatabase;
public class Mongoconnect {
public static void main(String args[]) {
try {
MongoClient mongoClient = new MongoClient(new MongoClientURI("mongodb://localhost:27017"));
MongoDatabase database;
database = mongoClient.getDatabase("test");
System.out.println("Connect to database successfully");
} catch (Exception e) {
System.err.println(e.getClass().getName() + ": " + e.getMessage());
}
}
}
這是我的第一次朋友...... – user3135049
所有更多理由密切關注你發佈的內容,提供的信息,工具,預覽。 .. –