Gradle ratpack中的非阻塞处理程序代码不工作

Gradle ratpack中的非阻塞处理程序代码不工作,gradle,groovy,ratpack,Gradle,Groovy,Ratpack,我试图遵循ratpack中的阻塞处理程序,但我无法让它工作。我正在获取缺少的背景方法异常 我的build.gradle文件如下所示 处理程序代码如下所示 import static ratpack.groovy.Groovy.ratpack ratpack { handlers { get("non-blocking") { background { Thread.sleep

我试图遵循ratpack中的阻塞处理程序,但我无法让它工作。我正在获取缺少的背景方法异常

我的build.gradle文件如下所示

处理程序代码如下所示

import static ratpack.groovy.Groovy.ratpack

    ratpack {
        handlers {
            get("non-blocking") {
                background {
                    Thread.sleep(10000)
                }.then{
                    response.send()
                }
            }
        }
    }
我正在获取缺少的背景方法异常

groovy.lang.MissingMethodException: No signature of method: nonBlocking.background() is applicable for argument types: (nonBlocking$_run_closure1$_closure2$_closure3$_closure4) values: [nonBlocking$_run_closure1$_closure2$_closure3$_closure4@497352d0]
    at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:58)
    at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.callCurrent(PogoMetaClassSite.java:81)
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:52)
    at 

你用的是什么Gradle版本?请记住,这个示例已经有将近4年的历史了,它使用了Gradle等旧版本的工具。例如,如果我使用Gradle
3.5-rc-2
version和do

./gradlew test
它将失败,并出现以下错误:

FAILURE: Build failed with an exception.

* Where:
Build file '/home/wololock/workspace/idea/stackoverflow-answers/46009278/build.gradle' line: 11

* What went wrong:
A problem occurred evaluating root project '46009278'.
> Failed to apply plugin [id 'ratpack-groovy']
   > Could not find method groovy() for arguments [DefaultExternalModuleDependency{group='io.ratpack', name='ratpack-groovy', version='0.9.4', configuration='default'}] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
现在,如果我们看看在开发这个示例时使用了什么Gradle版本,我们会发现根据项目文件,它使用了Gradle
1.10

如果定义了相同的Gradle包装器版本并执行以下操作:

./gradlew test

要运行应用程序,它应该工作:

10:39:44: Executing external task 'runFatJar'...
The groovy configuration has been deprecated and is scheduled to be removed in Gradle 2.0. Typically, usages of 'groovy' can simply be replaced with 'compile'. In some cases, it may be necessary to additionally configure the 'groovyClasspath' property of GroovyCompile and Groovydoc tasks.
:compileJava UP-TO-DATE
:compileGroovy UP-TO-DATE
:processResources UP-TO-DATE
:classes UP-TO-DATE
:fatJar
wrz 02, 2017 10:39:48 AM ratpack.server.internal.NettyRatpackServer start
INFO: Ratpack started for http://localhost:5050
:runFatJar
Sat Sep 02 10:40:40 CEST 2017 - received blocking request
Sat Sep 02 10:40:50 CEST 2017 - replying blocking request
Sat Sep 02 10:40:50 CEST 2017 - received non-blocking request
Sat Sep 02 10:41:00 CEST 2017 - replying non-blocking request

background
已被
阻塞所取代。获取

./gradlew test
./gradlew runFatJar
10:39:44: Executing external task 'runFatJar'...
The groovy configuration has been deprecated and is scheduled to be removed in Gradle 2.0. Typically, usages of 'groovy' can simply be replaced with 'compile'. In some cases, it may be necessary to additionally configure the 'groovyClasspath' property of GroovyCompile and Groovydoc tasks.
:compileJava UP-TO-DATE
:compileGroovy UP-TO-DATE
:processResources UP-TO-DATE
:classes UP-TO-DATE
:fatJar
wrz 02, 2017 10:39:48 AM ratpack.server.internal.NettyRatpackServer start
INFO: Ratpack started for http://localhost:5050
:runFatJar
Sat Sep 02 10:40:40 CEST 2017 - received blocking request
Sat Sep 02 10:40:50 CEST 2017 - replying blocking request
Sat Sep 02 10:40:50 CEST 2017 - received non-blocking request
Sat Sep 02 10:41:00 CEST 2017 - replying non-blocking request