Spring Integration SFTP - 重用现有的任务调度程序

时间:2018-01-24 08:53:02

标签: java spring spring-integration

在context.xml中使用此行时出现问题

def nodeName
stage('one'){
   node {
       nodeName = "${NODE_NAME}"
   }
}
stage('two'){
   node(nodeName) { 
       // this is the same node but another workspace
   }
}

它会抛出此错误

<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

那么如何让频道重用我自己的调度程序,而不是创建一个新的调度程序呢?或者有什么建议可以解决这个问题吗?

我正在使用Spring Integration v4.0.0。

2 个答案:

答案 0 :(得分:0)

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

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

答案 1 :(得分:0)

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

Documentation here