Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/352.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 我无法使用ApacheZ2调用该方法_Java_Apache Camel_Quartz Scheduler - Fatal编程技术网

Java 我无法使用ApacheZ2调用该方法

Java 我无法使用ApacheZ2调用该方法,java,apache-camel,quartz-scheduler,Java,Apache Camel,Quartz Scheduler,我需要调用基于cron模式的方法。这是我的java代码。我在其中包含了一个方法,这个方法我需要调用。我在google中尝试过,但不知道如何调用 public class Schedule { int i; public String show() { return "hi"+i++; } public static void main(String args[])throws Exception { CamelContext context = new Defau

我需要调用基于cron模式的方法。这是我的java代码。我在其中包含了一个方法,这个方法我需要调用。我在google中尝试过,但不知道如何调用

public class Schedule {
int i;
public  String  show()
{ 
    return "hi"+i++;

}

public static void main(String args[])throws Exception
{   
    CamelContext context = new DefaultCamelContext();
    context.addRoutes(new RouteBuilder() {
        public void configure() {
            from("quartz2://myGroup/myfirstrigger?cron=0/2+*+*+*+*+?").to(new      Schedule().show());

        }
    });
    context.start();    
}

 }

我也不确定这是否正确

您应该查看关于bean绑定()的文档。我认为你的路线会更好,如下所示:

from("quartz2://myGroup/myfirstrigger?cron=0/2+*+*+*+*+?")
  .bean(Schedule.class, "show");

我使用的是ApacheCammel,您提供的代码片段并不表明您已经启动了camel上下文。在camel上下文上调用start方法以使其工作。但我发现在JSP页面中启动camel上下文和调用其中方法的路由有点奇怪。您能解释一下您的完整用例吗?也发布在camel用户邮件列表上,在这里解释了答案-在像上面那样修改了我的代码之后,我得到了类似异常的结果。在这里,这是对所选方法的歧义。请阅读此处的相关文档: