我有服務在我從grailsApplicationgrailsApplication在服務沒有得到注入,Grails的2.1.0
訪問幾個配置屬性我注入像這樣
class MyWebService{
def grailsApplication
WebService webService = new WebService()
def getProxy(url, flag){
return webService.getClient(url)
}
def getResponse(){
def proxy = getProxy(grailsApplication.config.grails.wsdlURL, true)
def response = proxy.getItem(ItemType)
return response
}
}
當我打電話getProxy( )方法,我在tomcat日誌中看到這個
沒有方法的簽名:org.example.MyWebService.getProxy()適用於參數類型:(groovy.util.ConfigObject,java.lang.Boolean)values:[[ :],真] 可能的解決方案: getProxy(),getProxy(java.lang.String,boolean),setProxy(java.lang.Object)
這意味着grailsApplication沒有被注入服務,是否有任何替代方法來訪問配置對象?根據burtbeckwith的post配置持有者已被棄用,不能想到其他任何東西。
有趣的是,同樣的服務在我的本地IDE(GGTS 3.1.0)中工作正常,這意味着本地grailsApplication正在注入,但是當我創建一個部署到獨立tomcat的戰爭時,它會停止注入。
我看不到投票的理由,要麼你知道太多的Grails,或者你根本不知道它 –