簡體   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