getDeclaredMethod不断给出NoSuchMethodException

时间:2015-07-05 10:50:01

标签: java nosuchmethoderror

我看过一些关于使用getDeclaredMethod的NoSuchMethodException的帖子,但我仍然无法摆脱这个问题。

我将问题分离到了一个简单的问题,有人可以使这个工作:

public class MainMethodTest {

    public static void main(String[] args) {

        try {
            //Method m = MainMethodTest.class.getDeclaredMethod("main");
            Method m = MainMethodTest.class.getDeclaredMethod("main", MainMethodTest.class);
        } catch (NoSuchMethodException e) {
            e.printStackTrace();
        }
    }

}

2 个答案:

答案 0 :(得分:2)

$("#date_pretty").datepicker().datepicker("setDate", new Date());

尝试查找代码中没有的ActiveWindow.ActivePane.View.Type = wdOutlineView ActiveWindow.View.ShowHeading 3 Selection.MoveDown Unit:=wdParagraph 方法。

如果您想使用Method m = MainMethodTest.class.getDeclaredMethod("main", MainMethodTest.class); 方法

main(MainMethodTest argument)

答案 1 :(得分:0)

方法getDeclaredMethod的第二个参数是您想要获取的方法的参数。在你的情况下,它是主要的。所以你必须指定arg参数。

    Class[] argTypes = new Class[] { String[].class };
    Method main = MainMethodTest.class.getDeclaredMethod("main", argTypes); 

检查django-mysql如何调用main方法。