繁体   English   中英

Spring Integration SFTP-重用现有任务计划程序

[英]Spring Integration SFTP - Reuse existing task scheduler

我在context.xml中使用此行时遇到问题

<int:channel id="ftpChannel"/>

它抛出此错误

Could not autowire field: private org.springframework.core.task.TaskExecutor com.test.service.MyServices.taskExecutor; 
nested exception is org.springframework.beans.factory.NoUniqueBeanDefinitionException: No qualifying bean of type [org.springframework.core.task.TaskExecutor] is defined: expected single matching bean but found 2: myOwnScheduler,taskScheduler

似乎该频道创建了自己的任务计划程序,这困扰了我的自动装配属性

@Autowired(required = false)
private TaskExecutor taskExecutor;

那么,如何使频道重用我自己的调度程序,而不是创建一个新的调度程序? 还是有任何解决此问题的建议?

我正在使用Spring Integration v4.0.0。

您有两个类型为TaskExecutor的bean(具有以下名称:myOwnScheduler,taskScheduler),因此spring无法决定使用哪个bean。 所以他抛出了这个异常。 您需要使用这样的限定符:

@Qualifier("myOwnScheduler")
@Autowired(required = false)
private TaskExecutor taskExecutor;

您似乎对TaskSchedulerTaskExecutor感到困惑。 该框架提供了默认的调度程序(bean名称taskScheduler ),但是没有执行程序。

文档在这里

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM