Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/neo4j/3.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
调用eachParallel()时Groovy(GPars)和MissingMethodException_Groovy_Missingmethodexception_Gpars - Fatal编程技术网

调用eachParallel()时Groovy(GPars)和MissingMethodException

调用eachParallel()时Groovy(GPars)和MissingMethodException,groovy,missingmethodexception,gpars,Groovy,Missingmethodexception,Gpars,当我在控制台(groovy 2.1.3)中运行以下代码时: 我得到: groovy.lang.MissingMethodException: No signature of method: java.util.ArrayList.eachParallel() is applicable for argument types: (ConsoleScript40$_run_closure1) values: [ConsoleScript40$_run_closure1@a826f5] 有人能告诉我

当我在控制台(groovy 2.1.3)中运行以下代码时:

我得到:

groovy.lang.MissingMethodException: No signature of method: java.util.ArrayList.eachParallel() is applicable for argument types: (ConsoleScript40$_run_closure1) values: [ConsoleScript40$_run_closure1@a826f5]

有人能告诉我我做错了什么吗?

我想你错过了设置。试一试

@Grab(group='org.codehaus.gpars', module='gpars', version='1.0.0')
import groovyx.gpars.GParsPool

GParsPool.withPool {
    def strings =  [ "butter", "bread", "dragon", "table" ]
    strings.eachParallel { println it }
}

谢谢你,迈克尔。你确实让我走上了正确的轨道,尽管我无法进行抓取,因为我在一个代理后面。查看您的答案,我发现grooyy all的pom.xml中的GPAR依赖项设置为optional=true。这会导致默认情况下不包括gpar依赖项。因此,将gpar依赖项显式添加到pom中解决了这个问题。
@Grab(group='org.codehaus.gpars', module='gpars', version='1.0.0')
import groovyx.gpars.GParsPool

GParsPool.withPool {
    def strings =  [ "butter", "bread", "dragon", "table" ]
    strings.eachParallel { println it }
}