Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/docker/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
SpringBean注入在OpenShift上失败_Spring_Docker_Spring Boot_Dependency Injection_Openshift - Fatal编程技术网

SpringBean注入在OpenShift上失败

SpringBean注入在OpenShift上失败,spring,docker,spring-boot,dependency-injection,openshift,Spring,Docker,Spring Boot,Dependency Injection,Openshift,我在我们的Spring引导应用程序中添加了一个新的Spring集成配置和Spring消息传递。 应用程序在我的MAC上正确部署和运行 但是,, 部署到OpenShift(使用OpenJDK)或Docker运行时时 部署失败,出现以下错误: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.NoSuchBean

我在我们的Spring引导应用程序中添加了一个新的Spring集成配置和Spring消息传递。 应用程序在我的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 {

            }
        };
    }

}
import org.springframework.beans.factory.annotation.Qualifier;
导入org.springframework.messaging.MessageChannel;
导入org.springframework.stereotype.Service;
@服务
公共类FTP服务{
私有最终消息通道ftpClientInboundChannel;
公共FTP服务(@Qualifier(“ftpChannel”)消息通道ftpClientInboundChannel){
this.ftpClientInboundChannel=ftpClientInboundChannel;
}
}
导入org.springframework.context.annotation.Bean;
导入org.springframework.context.annotation.Configuration;
导入org.springframework.integration.annotation.IntegrationComponentScan;
导入org.springframework.integration.annotation.ServiceActivator;
导入org.springframework.messaging.Message;
导入org.springframework.messaging.MessageHandler;
导入org.springframework.MessagingException;
@配置
@集成组件扫描
公共类FtpClientConfiguration{
@豆子
@ServiceActivator(inputChannel=“ftpChannel”)
public MessageHandler ftpPayableHandler(){
返回新的MessageHandler(){
@凌驾
public void handleMessage(消息消息消息)引发MessaginException{
}
};
}
}

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

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