首页 > 其他 > 详细

Quartz不用配置文件配置启动

时间:2018-06-29 13:02:14      阅读:173      评论:0      收藏:0      [点我收藏+]
StdSchedulerFactory schedulerFactory = null;
        try {
            schedulerFactory = new StdSchedulerFactory();
            Properties prop = new Properties();
            /***************开始填写配置**********************/
            prop.put("org.quartz.scheduler.instanceName", zone); //zone为方法传进来的参数
            prop.put("org.quartz.scheduler.instanceId", "AUTO");
            prop.put("org.quartz.scheduler.rmi.export", "false");
            prop.put("org.quartz.scheduler.rmi.proxy", "false");
            prop.put("org.quartz.scheduler.wrapJobExecutionInUserTransaction", "false");
            prop.put("org.quartz.threadPool.class", "org.quartz.simpl.SimpleThreadPool");
            prop.put("org.quartz.threadPool.threadCount", "2");
            prop.put("org.quartz.threadPool.threadPriority", "5");
            prop.put("org.quartz.threadPool.threadsInheritContextClassLoaderOfInitializingThread", "true");
            prop.put("org.quartz.jobStore.misfireThreshold", "60000");
            prop.put("org.quartz.jobStore.class", "org.quartz.impl.jdbcjobstore.JobStoreTX");
            prop.put("org.quartz.jobStore.driverDelegateClass", "org.quartz.impl.jdbcjobstore.StdJDBCDelegate");
            prop.put("org.quartz.jobStore.useProperties", "true");
            prop.put("org.quartz.jobStore.isClustered", "false");
            prop.put("org.quartz.jobStore.tablePrefix", "qrtz_");
            prop.put("org.quartz.jobStore.dataSource", "qzDS");
            prop.put("org.quartz.dataSource.qzDS.driver", "com.mysql.jdbc.Driver");
            prop.put("org.quartz.dataSource.qzDS.URL", "jdbc:mysql://10.8.4.94:3306/shbi");
            prop.put("org.quartz.dataSource.qzDS.user", "root");
            prop.put("org.quartz.dataSource.qzDS.password", "root");
            prop.put("org.quartz.dataSource.qzDS.maxConnection", "10");
            /***************结束填写配置**********************/
            schedulerFactory.initialize(prop);
            scheduler = schedulerFactory.getScheduler();
//            JobDetail job = newJob(GitJob.class) //定义Job类为HelloQuartz类,这是真正的执行逻辑所在
//                    .withIdentity(tag, "group2") //定义name/group
//                    .usingJobData("name", tag) //定义属性
//                    .build();
//            Trigger trigger = TriggerBuilder.newTrigger()  
//                    .withIdentity("myTrigger")
//                    .withSchedule(cronSchedule("0 0/1 * * * ? ")) 
//                    .build();
//            scheduler.scheduleJob(job, trigger);
            scheduler.start();
        } catch (SchedulerException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

 

Quartz不用配置文件配置启动

原文:https://www.cnblogs.com/wpcnblog/p/9242705.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!