没有方法签名:static com.mongodb.MongoCredential.createCredential()

时间:2017-12-04 01:58:58

标签: mongodb groovy

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:没有方法签名:static com.mongodb.MongoCredential.createCredential()适用于参数类型:(java.lang.String,java.lang.String,[C)values:[elenalenenko ,test,p7Aqmlt9FF!]可能的解决方案:createPlainCredential(java.lang.String,java.lang.String,[C)错误在行:34

文档说语法是

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

1 个答案:

答案 0 :(得分:0)

好像是ReadyAPI 2.2.0的问题 回到ReadyAPI 2.1.0,一切都很完美。使用SmartBear提出支持票据