当前位置: 首页 > 知识库问答 >
问题:

JMeter/Beanshell“调用bsh方法时出错:eval源文件:

阴波峻
2023-03-14

爪哇


import java.util.LinkedHashMap;
import java.util.Map;

import org.bson.Document;

import com.mongodb.MongoClient;
import com.mongodb.MongoClientURI;
import com.mongodb.client.MongoCollection;
import com.mongodb.client.MongoDatabase;

public class MongoDB {

    public static MongoDatabase database;
    public static MongoClient mongoClients;

    public static void connect(String uri) {

        MongoClientURI uri_1 = new MongoClientURI(uri);
        // Connecting With Server
        mongoClients = new MongoClient(uri_1);
        System.out.println("server connection successfully done");

        database = mongoClients.getDatabase("Capacitacion");
        System.out.println("Connect to database successfully");
        System.out.println("DataBase Name: " + database.getName());
        MongoCollection<Document> col_Capacitacion_Liceo = database.getCollection("Liceo");


    } ```



jmeter

```import test.MongoDB;

MongoDB.connect(vars.get("uri"));;```
*

共有1个答案

子车勇锐
2023-03-14

Beanshell不是Java,不支持菱形运算符

如果出于某种原因,您确实需要使用Beanshell,请更改这一行:

 MongoCollection<Document> col_Capacitacion_Liceo = database.getCollection("Liceo");

对这个:

MongoCollection col_Capacitacion_Liceo = database.getCollection("Liceo");
 类似资料: