在网上查找的都是和tomcat一起使用的。我这个项目没有tomcat,我想通过main方法启动该怎么做呢?另外一个问题
 <!-- 每5秒执行一次 --> 
<cron-expression>0/5 * * * * ?</cron-expression> 
我想每天的凌晨0点执行这个表达式该怎么写呢?希望知道的高手不吝赐教。

解决方案 »

  1.   

    import org.quartz.Scheduler;
    import org.quartz.SchedulerException;
    import org.quartz.impl.StdSchedulerFactory;public class QuartzTest {    public static void main(String[] args) {        try {
                // Grab the Scheduler instance from the Factory 
                Scheduler scheduler = StdSchedulerFactory.getDefaultScheduler();            // and start it off
                scheduler.start();
                
                // Define job instance
               JobDetail job = new JobDetail("job1", "group1", MyJobClass.class);

                 // Define a Trigger that will fire "now"
                 Trigger trigger = new SimpleTrigger("trigger1", "group1", new Date());

               // Schedule the job with the trigger
               scheduler.scheduleJob(job, trigger);            
               // scheduler.shutdown();  //停止        } catch (SchedulerException se) {
                se.printStackTrace();
            }
        }
    }
      

  2.   

    LZ。
    你下的QUERY里面的DEMO,全都是MAIN启动的
      

  3.   

    字段名     允许的值     允许的特殊字符  
    秒     0-59     , - * /  
    分     0-59     , - * /  
    小时     0-23     , - * /  
    日     1-31     , - * ? / L W C  
    月     1-12 or JAN-DEC     , - * /  
    周几     1-7 or SUN-SAT     , - * ? / L C #  
    年 (可选字段)     empty, 1970-2099     , - * / 
    * * 0 * * ?  试试
      

  4.   

    http://www.blogjava.net/pojo/archive/2009/03/19/260908.html
      

  5.   

    大家能不能简单给我个实例程序看看功能只要实现每分钟打印一次当时时间就可以了。
    通过main方法运行的。我运行成功马上结贴。
      

  6.   

    配置 quartz.properties,使用 XML 加载配置,把 jobs 和 triggers 都写在一个 XML 配置中。就相当于这个文档上所说的:http://www.quartz-scheduler.org/docs/cookbook/JobInitPlugin.htmlQuartz example 10 就是采用这种方式的。
      

  7.   

    大家能不能简单给我个实例程序看看功能只要实现每分钟打印一次当时时间就可以了。
    通过main方法运行的。我运行成功马上结贴。
      

  8.   

    String configFile = "d:\\quartz.properties";
    String jobFile = "d:\\jobs.xml";
     FileInputStream fin = new FileInputStream(configFile);
            Properties configProperties = new Properties();
            configProperties.load(fin);
            configProperties.setProperty("org.quartz.plugin.jobInitializer.fileName", jobFile);
                StdSchedulerFactory factory=new StdSchedulerFactory(configProperties);
         r.setScheduler(factory.getScheduler());
         r.getScheduler().start();