Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Spring多个调度程序配置类与具有多个调度方法的单个调度程序配置类_Spring_Spring Boot - Fatal编程技术网

Spring多个调度程序配置类与具有多个调度方法的单个调度程序配置类

Spring多个调度程序配置类与具有多个调度方法的单个调度程序配置类,spring,spring-boot,Spring,Spring Boot,我有两个来自两个不同组件的调度器。我可以创建两个配置类,每个类都有对应组件的调度方法,或者创建一个同时有两个调度方法的配置类。这两个选项之间有什么区别吗?每个计划的方法是创建线程还是共享线程 选择1 @Configuration @EnableScheduling public class SchedulerAConfig { @Scheduled public void a() {} } @Configuration @EnableScheduling public class

我有两个来自两个不同组件的调度器。我可以创建两个配置类,每个类都有对应组件的调度方法,或者创建一个同时有两个调度方法的配置类。这两个选项之间有什么区别吗?每个计划的方法是创建线程还是共享线程

选择1

@Configuration
@EnableScheduling
public class SchedulerAConfig {

   @Scheduled
   public void a() {}
}

@Configuration
@EnableScheduling
public class SchedulerBConfig {

    @Scheduled
    public void b() {}
}
选择2

@Configuration
@EnableScheduling
public class SchedulerConfig {

    @Scheduled
    public void a() {}

    @Scheduled
    public void b() {}
}