首先,我们看下上个博文(CronTrigger 示例2 中部分打印的日志内容)
[INFO] 17 一月 09:41:40.016 下午 MyScheduler_Worker-9 [com.example03.SimpleJob]
SimpleJob says: group1.job1 executing at Fri Jan 17 21:41:40 CST 2020
看到 group1.job1 了没,它是由如下代码打印的.
Jobkey打印的内容是 group1.job1 .
我们先来看看JobKey的源码内容
public final class JobKey extends Key<JobKey> {
private static final long serialVersionUID = -6073883950062574010L;
public JobKey(String name) {
super(name, null);
}
public JobKey(String name, String group) {
super(name, group);
}
public static JobKey jobKey(String name) {
return new JobKey(name, null);
}
public static JobKey jobKey(String name, String group) {
return new JobKey(name, group);
}
}
它继承了Key 接口 ,里面有个toString方法 ,由此,可以知晓jobKey的内容.
/**
* <p>
* Return the string representation of the key. The format will be:
* <group>.<name>.
* </p>
*
* @return the string representation of the key
*/
@Override
public String toString() {
return getGroup() + '.' + getName();
}
public class Key<T> implements Serializable, Comparable<Key<T>> {
private static final long serialVersionUID = -7141167957642391350L;
/**
* The default group for scheduling entities, with the value "DEFAULT".
*/
public static final String DEFAULT_GROUP = "DEFAULT";
private final String name;
private final String group;
由上面的代码片段可以看出, Job的默认组名称为 "DEFAULT" 。