簡體   English   中英

Spring 遷移到 spring 后出現集成錯誤 5

[英]Spring integration errors after migration to spring 5

我一直在使用 Spring 集成(不同類型的頻道)與 Spring 4 一段時間。 在我嘗試將我的環境升級到 Spring 5 后,他們停止工作並出現如下錯誤:

org.springframework.messaging.MessageHandlingException:在“MethodInvokingMessageProcessor”中處理消息時發生錯誤 [org.springframework.integration.handler.MethodInvokingMessageProcessor@c192373]; 嵌套異常是 java.lang.IllegalArgumentException:BeanFactory 不能是 null,failedMessage=GenericMessage

頻道創建/注冊示例如下:

deltaupdatedchannel = new DirectChannel(); deltaupdatedchannel.setBeanName("deltaupdatedcontroller");

    serviceActivator = new ServiceActivatingHandler(deltaSummaryController, "updateDelta2");
    handlerlist.add(serviceActivator);
    
    
    
    beanFactory.registerSingleton("deltaupdatedcontroller", deltaupdatedchannel);
    beanFactory.initializeBean(deltaupdatedchannel, "deltaupdatedcontroller");
    deltaupdatedchannel.subscribe(serviceActivator);

通道用於進行以下調用:this.deltaupdatedcontrollerchannel.send(MessageBuilder.withPayload(summarydto).build());

頻道調用以下代碼:

public void updateDelta2(DeltaSummaryDTO dto) {

    this.messagingTemplate.convertAndSend(
            "/topic/updatedelta", dto);
}

這里的messagingTemplate是org.springframework.messaging.core.MessageSendingOperations。

我怎樣才能讓他們再次工作?

請與我們分享這樣做的原因registerSingleton() 為什么僅僅簡單的 bean 注冊對你來說還不夠?

要解決該問題,您還需要在registerSingleton()之后調用initializeBean(Object existingBean, String beanName) ) 。

但是,不能保證這將是錯誤的終結。 我建議修改一個設計以支持普通的 bean 定義,而不是那個手動的定義......

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM