如何解决在某些情况下,RESTClient实例在Groovy服务中为null
我正在使用grails 2.4.0。
在resources.groovy中-
oauthRestClient(wslite.rest.RESTClient) {
println Holders.config."$Holders.config.citruspay.consumerPortal.env".oAuth.baseURL
url = Holders.config."$Holders.config.citruspay.consumerPortal.env".oAuth.baseURL
httpClient = ref('oauthHttpClient')
}
在服务文件UserProfileService.groovy中-一种新定义的方法-
class UserProfileService {
def oauthRestClient
def getAccountDisabledStatusDummy(String owner) {
log.info("In getAccountDisabledStatus Service for owner ")
log.info("*****************************************")
def restClient = oauthRestClient
log.info "restClient in getAccountDisabledStatusDummy "+restClient
}
这由SomeController.groovy文件调用-
class SomeController {
def userProfileService
def checkUser(){
..
def disableResponse = userProfileService.getAccountDisabledStatusDummy(userId)
..
}
}
这是Ajax从gsp文件中调用的。
输出-
restClient显示为空。
我尝试通过现有服务方法中的复制粘贴进行操作,但未成功。即使当一个UserProfileService method1()调用在checkUser内的同一流程中运行正常时,如果我将其复制到method2()并稍后调用,它也可以在第一个AJAX调用中工作,然后在第二个调用中给出null。
第一次通话-
getAccountDisabledStatusDummy中的restclient wslite.rest.RESTClient@6b319ef3
第二次通话-
getAccountDisabledStatusDummy中的restclient null
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。