我正在尝试遵循this blogpost,该示例演示了ratpack中的阻塞处理程序,但无法正常工作。我正在为背景缺少方法异常。

我的build.gradle文件如下this GitHub directory

buildscript {
    repositories {
    maven { url "http://oss.jfrog.org/artifactory/repo" }
    jcenter()
  }
  dependencies {
    classpath 'io.ratpack:ratpack-gradle:0.9.4'
  }
}

apply plugin: "ratpack-groovy"
apply plugin: "idea"
apply plugin: "eclipse"

repositories {
  maven { url "http://oss.jfrog.org/artifactory/repo" }
  jcenter()
  maven { url "http://repo.springsource.org/repo" }
  maven { url "https://nexus.codehaus.org/content/repositories/snapshots/" }
}

dependencies {
  springloaded "org.springsource.loaded:springloaded:1.1.5.RELEASE"

  testCompile "org.spockframework:spock-core:0.7-groovy-2.0", {
      exclude module: "groovy-all"
  }
}

// The Groovy that rest-assured drags in via ratpack-groovy-test is toxic, prevent it from coming in
// This should be fixed upstream in Ratpack
configurations.testCompile.dependencies.find { it.name == "ratpack-groovy-test" }.exclude(group: "org.codehaus.groovy")

处理程序代码如下。
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

最佳答案

此后background已替换为Blocking.get
https://ratpack.io/manual/current/api/ratpack/exec/Blocking.html#get-ratpack.func.Factory-

08-18 23:40