我对Groovy编程非常新手。我编写了一个API,它在我的本地系统(localhost:2100
)上运行。
现在我想使用Groovy代码向这个API发起简单的GET请求。我找了很多相关资料,但没有找到清晰的指导。
我尝试了像这样的方法:
http://www.kellyrob99.com/blog/2013/02/10/groovy-and-http/ http://rest.elkstein.org/2008/02/using-rest-in-groovy.html等等,但都无法正常工作。
此外,我还了解到了HttpBuilder
,但是我不能很清楚地理解它,请分享你的想法。
编辑:
我尝试了下面的方法:
def client = new RESTClient("http://localhost:2100");
def res = client.get(path:"xxx/yyy/zzz")
我收到了错误信息:
Groovy:unable to resolve class RESTClient
我是否需要在我的pom.xml文件中添加依赖?