Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/spring-mvc/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Grails 可以使用map作为输入变量配置slurper解析方法_Grails_Groovy - Fatal编程技术网

Grails 可以使用map作为输入变量配置slurper解析方法

Grails 可以使用map作为输入变量配置slurper解析方法,grails,groovy,Grails,Groovy,我正试图像这样使用config slurper解析groovy文件 fileContents = '''deployment { deployTo('dev') { test = me } }''' def config = new ConfigSlurper().parse(fileContents) 上面的代码之所以有效,是因为deployto('dev')只接受一个字符串。但我给它添加了一个额外的参数,它失败了,但有一个例外: fileContents = '''deploy

我正试图像这样使用config slurper解析groovy文件

fileContents = '''deployment {
  deployTo('dev') {
test = me
  }
  }'''
def config = new ConfigSlurper().parse(fileContents)
上面的代码之所以有效,是因为deployto('dev')只接受一个字符串。但我给它添加了一个额外的参数,它失败了,但有一个例外:

fileContents = '''deployment {
  deployTo('dev','qa') {
test = me
  }
  }'''
def config = new ConfigSlurper().parse(fileContents)
它失败,但出现以下异常:

捕获:groovy.lang.MissingMethodException:没有方法的签名:groovy.util.ConfigSlurper$\u parse\u closure5.deployTo()适用于参数类型:(java.lang.String、java.lang.String、script15047332444361539770645$\u run\u closure3$\u closure10)值:[开发、后期运行、script15047332444361539770645$\u run\u closure3$_closure10@6b8ca3c8]


有没有办法在模块中读取带有额外参数的配置文件?

您就快到了。要使用值列表,请执行以下更改

发件人:

致:

它将是:

def fileContents = '''deployment {   deployTo(['dev','qa']) { test = me   }   }''' 
def config = new ConfigSlurper().parse(fileContents)​

Ishu,请检查解决方案,看看是否可以解决。谢谢@Rao,这需要更改我需要解析的文件,这是不可能的。但看起来这是唯一的出路。
deployTo(['dev','qa'])
def fileContents = '''deployment {   deployTo(['dev','qa']) { test = me   }   }''' 
def config = new ConfigSlurper().parse(fileContents)​