正在尝试通过jmeter查询mongodb。我已经下载了 mongodb-driver-sync-4.2.3.jar
从maven复制到 lib
及 lib/ext
文件夹。
我的JSR223采样器代码基本上是mongo快速启动代码的复制粘贴:
import com.mongodb.ConnectionString;
import com.mongodb.MongoClientSettings;
import com.mongodb.client.MongoClient;
import com.mongodb.client.MongoClients;
import com.mongodb.client.MongoDatabase;
def connectionString = new ConnectionString("CONNECTION_STRING");
def settings = MongoClientSettings.builder()
.applyConnectionString(connectionString)
.build();
def mongoClient = MongoClients.create(settings);
def database = mongoClient.getDatabase("test");
但我不断收到错误消息,说导入失败:
Script2.groovy: 1: unable to resolve class com.mongodb.ConnectionString
@ line 1, column 1.
import com.mongodb.ConnectionString;
^
Script2.groovy: 2: unable to resolve class com.mongodb.MongoClientSettings
@ line 2, column 1.
import com.mongodb.MongoClientSettings;
^
2 errors
javax.script.ScriptException: org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
Script2.groovy: 1: unable to resolve class com.mongodb.ConnectionString
@ line 1, column 1.
import com.mongodb.ConnectionString;
^
Script2.groovy: 2: unable to resolve class com.mongodb.MongoClientSettings
@ line 2, column 1.
import com.mongodb.MongoClientSettings;
我错过了什么?我该怎么做?
1条答案
按热度按时间4uqofj5v1#
lib/ext
文件夹用于jmeter插件,mongodb驱动程序应该只转到“lib”文件夹您需要重新启动jmeter以获取.jar。
mongodb-driver-sync-4.2.3.jar
本质上不提供com.mongodb.connectionstring,该类位于mongodb-driver-core-4.2.3.jar中根据打开连接后的操作,您可能还需要在jmeter类路径中包含bson-4.2.3.jar
更多信息:使用jmeter进行mongodb性能测试