简体   繁体   English

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

[英]Spring Integration SFTP - Reuse existing task scheduler

I have a problem when using this line in my context.xml 我在context.xml中使用此行时遇到问题

<int:channel id="ftpChannel"/>

It throws this error 它抛出此错误

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

It seems like the channel create its own task scheduler and it troubles my autowired properties 似乎该频道创建了自己的任务计划程序,这困扰了我的自动装配属性

@Autowired(required = false)
private TaskExecutor taskExecutor;

So how can I make the channel reuse back my own scheduler, instead of creating a new one ? 那么,如何使频道重用我自己的调度程序,而不是创建一个新的调度程序? Or is there any suggestion to fix this ? 还是有任何解决此问题的建议?

I'm using Spring Integration v4.0.0. 我正在使用Spring Integration v4.0.0。

You have two bean (with the following names: myOwnScheduler, taskScheduler) of type TaskExecutor so spring can't decide which one to use. 您有两个类型为TaskExecutor的bean(具有以下名称:myOwnScheduler,taskScheduler),因此spring无法决定使用哪个bean。 So he throws this exception. 所以他抛出了这个异常。 You need to use a qualifier like this: 您需要使用这样的限定符:

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

You seem to be confusing TaskScheduler and TaskExecutor . 您似乎对TaskSchedulerTaskExecutor感到困惑。 The framework provides a default scheduler (bean name taskScheduler ), but not an executor. 该框架提供了默认的调度程序(bean名称taskScheduler ),但是没有执行程序。

Documentation here . 文档在这里

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

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