标签:text on() source word app xmla err turn kconfig
public class JobMain { //配置注册中心 private ZookeeperConfiguration zkConfig = new ZookeeperConfiguration(PropertiesUtil.getProperty("config/route.properties","zookeeper.url"),"third_recon_job"); private CoordinatorRegistryCenter regCenter = new ZookeeperRegistryCenter(zkConfig); /** 创建任务 *JobCoreConfiguration.newBuilder("任务名称", "corn表达式", 所在分片 ).description("任务描述说明").build() *BlackListJob.class 任务类 */ private final LiteJobConfiguration blackListJob = LiteJobConfiguration.newBuilder( new SimpleJobConfiguration(JobCoreConfiguration.newBuilder("blackListJob", "0 0 15 3 * ?", 1) .description("1:拉取黑名单").build(), BlackListJob.class.getCanonicalName())).build(); /** * 配置数据源连接 **/ public static JobEventConfiguration createJobEventConfiguration() { DriverManagerDataSource dataSource = new DriverManagerDataSource(); dataSource.setUsername(PropertiesUtil.getProperty("config/datasource.properties", "jdbc.username")); dataSource.setPassword(PropertiesUtil.getProperty("config/datasource.properties", "jdbc.password")); dataSource.setDriverClassName(PropertiesUtil.getProperty("config/datasource.properties", "jdbc.driver.class")); dataSource.setUrl(PropertiesUtil.getProperty("config/datasource.properties", "jdbc.url")); JobEventConfiguration jobEventConfig = new JobEventRdbConfiguration(dataSource); return jobEventConfig; } public void init() { //加载spring配置 ReconciliationTaskConstant.setContext(new ClassPathXmlApplicationContext("applicationContext/application*context.xml")); // 连接注册中心 regCenter.init(); // 初始化作业 new JobScheduler(regCenter, blackListJob, createJobEventConfiguration()).init(); //拉取黑名单任务 } public static void main(String[] args) { new JobMain().init(); } } /**** ** 简单任务类 */ public class BlackListJob implements SimpleJob { @Override public void execute(ShardingContext shardingContext) { //context.getShardingItem()获取分片,根据不同的分片,执行不同的任务 System.out.println("开始执行不分片的简单任务"); } }
执行方式:
直接打包成jar,然后:
java -jar xxxxx.jar
标签:text on() source word app xmla err turn kconfig
原文地址:http://www.cnblogs.com/chauvet/p/7992932.html