我对Groovy和HttpBuilder库有奇怪的问题。首先要注意,我对 Groovy 很陌生。
我的代码基于教程。它只是从 HTTP 服务器加载文件列表。该代码昨天有效,今天(工作区构建后)无效。
问题是:
Caught: groovy.lang.MissingMethodException: No signature of method: groovyx.net.http.HTTPBuilder.request() is applicable for argument types: (groovyx.net.http.Method, groovyx.net.http.ContentType, pl.linfo.groovy.samples.HttpTest$_main_closure1)
Possible solutions: request(groovyx.net.http.Method, groovy.lang.Closure)
代码是:
def http = new HTTPBuilder( 'http://nbp.pl/Kursy/xml/dir.txt' )
http.request( GET, TEXT ) {
response.success = { resp, reader ->
println "${resp.statusLine}"
files = reader.text.split ('\r\n')
}
response.'404' = {
println "Not found!"
return
}
};
运行环境为Eclipse 3.6
我想问题是 groovy 编译问题,重新编译后的 groovy 代码片段不再匹配 Closure。但是,作为 Groovy 的新手,我很难找出发生了什么,所以请帮忙。