java - 没有 xml 配置的 Spring @Async

标签 java spring asynchronous annotations executor

25.5.3 The Element

To enable both @Scheduled and @Async annotations, simply include the 'annotation-driven' element from the task namespace in your configuration.

<task:annotation-driven executor="myExecutor" scheduler="myScheduler"/>

<task:executor id="myExecutor" pool-size="5"/>

<task:scheduler id="myScheduler" pool-size="10"/>

Notice that an executor reference is provided for handling those tasks that correspond to methods with the @Async annotation, and the scheduler reference is provided for managing those methods annotated with @Scheduled.

有没有不用 XML 就可以做到这一点的方法?

最佳答案

这对于新发布的 Spring 3.1 是可能的,但不是 3.0 - 参见 @EnableAsync@EnableScheduling .

关于java - 没有 xml 配置的 Spring @Async,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8719723/

相关文章:

java - 类字段同时具有@Autowired 注释和右手赋值

java - 从 Spring Integration 启动 Spring Batch 作业

java - Spring XML 406 错误

java - HornetQ集群队列和故障节点: are messages lost?

java - Hibernate 延迟加载属性 XML 映射

java - 标准化 XML 阅读器方法

java - Spring AOP异常多态

java - 效率 - 在等待变量更改的循环中使用 Thread.yield

javascript - 多个 Google map 会减慢 WordPress 管理速度

javascript - 异步 SQL 循环插入