我想在groovy脚本上写一个脚本,但是我有这个例外:
Caught: groovy.lang.MissingMethodException: No signature of method: ru.evgeny.in.order.bob.util.dbutil.DBStandaloneFullXMLUtil.randomShippingMethod() is applicable for argument types: () values: []
Possible solutions: getRandomShippingMethod()
groovy.lang.MissingMethodException: No signature of method: ru.evgeny.in.order.bob.util.dbutil.DBStandaloneFullXMLUtil.randomShippingMethod() is applicable for argument types: () values: []
Possible solutions: getRandomShippingMethod()
at Draft.run(Draft.groovy:6)
我的常规脚本:
import ru.evgeny.in.order.bob.util.dbutil.DBStandaloneFullXMLUtil
def db = new DBStandaloneFullXMLUtil()
println db.getRandomSKU()
println db.randomShippingMethod()
DBStandaloneFullXMLUtil:
class DBStandaloneFullXMLUtil implements IDBUtil {
....
@Override
def getRandomSKU() {
def rows = 'id, item_nr'
def table = '(select * from mywms_itemdata where dtype = \'LMItemData\') as LMItemData'
getRandomeRow(rows, table).values()
}
@Override
def getRandomShippingMethod(){
def rows = 'id, name'
def table = 'lm_shipping_method'
getRandomeRow(rows, table).values()
}
}
为什么我会收到此例外???为什么没有例外
println db.getRandomSKU()
答案 0 :(得分:0)
问题是您的类中有两个访问器方法:android.app.Application cannot be cast to android.support.v4.app.FragmentActivity
和getRandomSKU
,但是您用两种不同的方式调用它们:
getRandomShippingMethod
您应将以上内容更改为:
println db.getRandomSKU()
println db.randomShippingMethod()
(间接调用您的访问器方法),或者您可以使用:
println db.randomSKU
println db.randomShippingMethod
(直接调用这些方法)