【问题标题】:No signature of method: static com.mongodb.MongoCredential.createCredential()没有方法签名:静态 com.mongodb.MongoCredential.createCredential()
【发布时间】:2017-12-04 01:58:57
【问题描述】:

MongoCredential.createCredential() 对根据文档(Groovy with gmongo)看似有效的参数抛出错误响应。

我正在尝试执行的代码:

@Grab(group='com.gmongo', module='gmongo', version='1.5')

import java.util.*;
import com.gmongo.GMongo
import com.gmongo.GMongoClient
import com.mongodb.MongoCredential
import com.mongodb.MongoClientOptions
import com.mongodb.client.MongoDatabase; 
import com.mongodb.*
import com.mongodb.ServerAddress
import com.gmongo.*
import com.mongodb.MongoURI
import com.mongodb.DBCursor;
import com.mongodb.BasicDBObject;
import com.mongodb.BasicDBList

def mongoendpoint = context.expand( '${#Project#mongoendpoint}' )
def mongocollection=context.expand( '${#Project#mongocollection_ignition}' )
char[] password = 'password'.toCharArray();

 def credentials = MongoCredential.createCredential(
           context.expand('${#Project#MongoUser}'),
           context.expand('${#Project#MongoDatabase}'),
           password
           // "password" as char[] doesn't work either
           )

得到以下错误:

groovy.lang.MissingMethodException:没有方法签名:静态 com.mongodb.MongoCredential.createCredential() 适用于参数类型:(java.lang.String, java.lang.String, [C) 值:[elenalenenko , test, p7Aqmlt9FF!] 可能的解决方案:createPlainCredential(java.lang.String, java.lang.String, [C) error at line: 34

文档说语法是

static MongoCredential  createCredential(String userName, String database, char[] password)

【问题讨论】:

  • 无法在我的机器上重现您的错误。你能提供完整的堆栈跟踪和上下文的定义吗?
  • 这是 ReadyAPI 2.2.0 的问题。我收到了 SmartBear 人员的回复,他们建议我从 lib 文件夹中删除 mongo-java-driver,并附上评论:“在上一个版本中,将 mongo-java-driver-2.12.3.jar 驱动程序添加到了 ReadyAPI安装。因此,ReadyAPI 指的是该驱动程序的旧版本,而不是您添加到 ReadyAPI_Install\bin\ext 文件夹中的版本。” ReadyAPI 2.1.0 中一切正常,无需任何更改

标签: mongodb groovy


【解决方案1】:

似乎是 ReadyAPI 2.2.0 的问题 回滚到 ReadyAPI 2.1.0,一切正常。使用 SmartBear 提出支持请求

【讨论】:

    猜你喜欢
    • 2011-12-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-09-24
    • 1970-01-01
    • 1970-01-01
    • 2020-02-15
    相关资源
    最近更新 更多