Quartz不用配置文件配置启动
Posted wpcnblog
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Quartz不用配置文件配置启动相关的知识,希望对你有一定的参考价值。
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不用配置文件配置启动的主要内容,如果未能解决你的问题,请参考以下文章