spring boot多任务配置

@SpringBootApplication
@EnableScheduling
public class Application {


public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}


@Configuration
@ImportResource("/applicationContext.xml")
class XmlImportingConfiguration {

}


<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xmlns:task="http://www.springframework.org/schema/task"
    xmlns:context="http://www.springframework.org/schema/context"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-3.0.xsd">


    <!-- Enables the Spring Task @Scheduled programming model -->
    <task:executor id="executor" pool-size="5" />
    <task:scheduler id="scheduler" pool-size="10" />
    <task:annotation-driven executor="executor" scheduler="scheduler" />


</beans>


配置并行任务只需配置spring boot的配置文件applicationContext.xml如上.


这是第一个中篇,不是因为这个知识点有多难,而是它让老衲体会到了spring boot的博大精深与深不可测,以及老衲的渺小。更重要的是明白了

面对问题需要冷静,认真找准突破口.

展开阅读全文

没有更多推荐了,返回首页