1
我正在爲使用Camel的Spring Boot應用程序進行單元測試。當應用程序運行時,它可以得到被配置爲@Component無法獲取@Component作爲Bean在單元測試中使用Apache Camel進行Spring Boot應用程序
@Component("agencyExporterProcessor")
public class AgencyExporterProcessor {}
豆,我得到這個bean是這樣的:
from(getTriggerExportEndpoint())
.routeId(getTriggerExportId())
// When shutting down, Camel will wait until the batch completed
.shutdownRunningTask(ShutdownRunningTask.CompleteAllTasks)
.log("[SamCustomExporter] - RouteId:${routeId} - Begin at ${date:now:MM/dd/yyyy HH:mm:ss.SSS}")
.setHeader(Messaging.Names.SAM_DATA_AGENCY_CONFIGURATION_HEADER_KEY.toString(), constant(getConfiguration()))
// Initialize a list to store exported CSV file names
.bean(agencyExporterProcessor, "prepareExportedFileList")
但是當我測試,路線不能得到豆」
org.apache.camel.FailedToCreateRouteException: Failed to create route agencyExporterRoute_triggerExport at: >>> Bean[ref:agencyExporterProcessor method:prepareExportedFileList] <<< in route: Route(agencyExporterRoute_triggerExport)[[From[direct:agency... because of No bean could be found in the registry for: agencyExporterProcessor
這是我如何配置我的單元測試類:
@DirtiesContext
@RunWith(SpringRunner.class)
@EnableAutoConfiguration
@SpringBootApplication
@SpringBootTest(classes = SamCustomExporterSpringApplication.class,
webEnvironment = SpringBootTest.WebEnvironment.NONE)
public class AgencyExporterRouteTest extends BaseRouteTestSupport {}
請給意見!!!!非常感謝
對不起,這是我的錯誤,當我複製的代碼。是的,我確實喜歡你,易卜生先生。但它仍然有這個錯誤 –
基本包應該是相同的組件掃描。兩個課程的包裝位置是什麼? – priyas