Commit 04ae571a authored by 冯景珉's avatar 冯景珉

Update 计划任务.md

parent d2c339e1
...@@ -40,14 +40,14 @@ ...@@ -40,14 +40,14 @@
#### 2.3 任务类的编写 #### 2.3 任务类的编写
想要自定义一个job,必须要继承一个抽象类AbstractJob,然后在`safeExecute()`方法中执行业务代码,示例代码如下: 想要自定义一个job,必须要继承一个抽象类AbstractJob或者AbstractJobWithIRequest,然后在`safeExecute()`方法中执行业务代码,示例代码如下:
```java ```java
public class demoJob extends AbstractJob{ public class demoJob extends AbstractJob{
@Autowired @Autowired
private xxxService service;//业务类 private xxxService service;//业务类
@Override @Override
public void safeExecute(JobExecutionContext jobExecutionContext) throws Exception { public void safeExecuteWithIRequest(JobExecutionContext jobExecutionContext) throws Exception {
//map中可以获取上方定义的参数,key为参数名称,value为参数值 //map中可以获取上方定义的参数,key为参数名称,value为参数值
JobDataMap map = jobExecutionContext.getMergedJobDataMap(); JobDataMap map = jobExecutionContext.getMergedJobDataMap();
try { try {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment