【发布时间】:2014-08-21 13:39:36
【问题描述】:
我正在使用 Grails/Groovy,并且有一些使用 groovy-wslite 的直接 Groovy 代码。那段代码就是这样开始的
send-request.groovy
@Grab(group='com.github.groovy-wslite', module='groovy-wslite', version='1.1.0')
import wslite.soap.*
当我在我的 Grails 代码中实现它并查看控制器/动作时,我得到了这个
Error 500: Internal Server Error
URI: /FormProj/hello/trigger
Class: java.lang.RuntimeException
Message: No suitable ClassLoader found for grab
这是当前状态的代码(我尝试了很多不同的东西)
HelloController.groovy
package com.demo
import groovy.grape.Grape
class HelloController {
def index() { }
def sayHi() {
return [
greeting : "Hi there, ${ params.name }"
]
}
def trigger() {
Grape.grab(group:'com.github.groovy-wslite', module:'groovy-wslite', version:'1.1.0')
…
}
}
我相信你会注意到我对 Grails/Groovy 和 Java 的一切都很熟悉。我知道有一个用于 Grails 的 wslite 插件,但这肯定也可以正常工作吗?
Grails:2.3.8
Groovy:2.2.2
更新
根据 Ian Robert 的建议,我更新了我的 BuildConfig 文件,将此行添加到 dependencies 块
compile 'com.github.groovy-wslite:groovy-wslite:1.1.0'
并将我的控制器更新为如下所示
HelloController.groovy
package ws.thejspot
import wslite.soap.*
class HelloController {
def index() { }
def sayHi() {
return [
greeting : "Hi there, ${ params.name }"
]
}
def trigger() {
def client = new SOAPClient('URL')
}
}
不幸的是,现在 IDE GGTS 在控制器中显示错误“无法解析类 SOAPClient”
【问题讨论】: