一、测试
public class MrBatchApp {
// Log
private static final Log log = LogFactory.getLog(MrBatchApp.class);
//
public static void main(String[] args) throws JobParametersInvalidException, JobExecutionAlreadyRunningException, JobRestartException, JobInstanceAlreadyCompleteException {
System.out.println("TEST");
// 加载对应的xml配置文件
AbstractApplicationContext context = new ClassPathXmlApplicationContext("classpath:/META-INF/spring/*-context.xml");
log.info("Batch Tweet Hashtag MR Job Running");
// 关闭"钩子" 为了方便在适当的时候关闭 spring ioc
// (在非web环境下,关闭spring ioc需要手动完成)
context.registerShutdownHook();
// job 发射器
// JobLaucher是一个简化的job的控制接口;基于运行时不同的标识
// 该接口并不能确保执行job是同步还是异步
JobLauncher jobLauncher = context.getBean(JobLauncher.class);
// job
Job job = context.getBean(Job.class);
// 运行job
jobLauncher.run(job, new JobParameters());
}
}
二、xml配置文件
(1)、common 配置
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http
public class MrBatchApp {
// Log
private static final Log log = LogFactory.getLog(MrBatchApp.class);
//
public static void main(String[] args) throws JobParametersInvalidException, JobExecutionAlreadyRunningException, JobRestartException, JobInstanceAlreadyCompleteException {
System.out.println("TEST");
// 加载对应的xml配置文件
AbstractApplicationContext context = new ClassPathXmlApplicationContext("classpath:/META-INF/spring/*-context.xml");
log.info("Batch Tweet Hashtag MR Job Running");
// 关闭"钩子" 为了方便在适当的时候关闭 spring ioc
// (在非web环境下,关闭spring ioc需要手动完成)
context.registerShutdownHook();
// job 发射器
// JobLaucher是一个简化的job的控制接口;基于运行时不同的标识
// 该接口并不能确保执行job是同步还是异步
JobLauncher jobLauncher = context.getBean(JobLauncher.class);
// job
Job job = context.getBean(Job.class);
// 运行job
jobLauncher.run(job, new JobParameters());
}
}
二、xml配置文件
(1)、common 配置
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http