在OpenShift上Spring Bean注入失败

我在Spring Boot应用程序中添加了一个Spring Messaging的新Spring集成configuration。 应用程序在我的MAC上正确部署和运行。

但是,当部署到OpenShift(使用OpenJDK)或Docker运行时部署失败,并出现以下错误:

Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'org.springframework.messaging.MessageChannel' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Qualifier(value=ftpChannel)} 

下面是代码失败的一个简化的版本以相同的错误:

 import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.messaging.MessageChannel; import org.springframework.stereotype.Service; @Service public class FtpService { private final MessageChannel ftpClientInboundChannel; public FtpService(@Qualifier("ftpChannel") MessageChannel ftpClientInboundChannel) { this.ftpClientInboundChannel = ftpClientInboundChannel; } } import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.integration.annotation.IntegrationComponentScan; import org.springframework.integration.annotation.ServiceActivator; import org.springframework.messaging.Message; import org.springframework.messaging.MessageHandler; import org.springframework.messaging.MessagingException; @Configuration @IntegrationComponentScan public class FtpClientConfiguration { @Bean @ServiceActivator(inputChannel = "ftpChannel") public MessageHandler ftpPayableHandler() { return new MessageHandler() { @Override public void handleMessage(Message<?> message) throws MessagingException { } }; } } 

该问题已通过添加消息通道bean来解决:

 @Bean public MessageChannel ftpChannel() { return new DirectChannel(); }