Spring integration 如何使用SFTP出站网关&x27;mget&x27;下载文件的命令?
我想使用'mget'命令从sftp服务器下载文件。以下是我的java配置:Spring integration 如何使用SFTP出站网关&x27;mget&x27;下载文件的命令?,spring-integration,Spring Integration,我想使用'mget'命令从sftp服务器下载文件。以下是我的java配置: @Bean public SessionFactory<ChannelSftp.LsEntry> sftpSessionFactory() { DefaultSftpSessionFactory factory = new DefaultSftpSessionFactory(true); .... return new CachingSessionFactory<>
@Bean
public SessionFactory<ChannelSftp.LsEntry> sftpSessionFactory() {
DefaultSftpSessionFactory factory = new DefaultSftpSessionFactory(true);
....
return new CachingSessionFactory<>(factory);
}
@Bean(name = "lsGateway")
@ServiceActivator(inputChannel = "sftpChannel")
public MessageHandler handlerLs() {
// call 'mget' command to download all the files in server folder
SftpOutboundGateway sftpOutboundGateway = new SftpOutboundGateway(sftpSessionFactory(), "mget", "payload");
sftpOutboundGateway.setLocalDirectory(new File("/local/path"));
return sftpOutboundGateway;
}
我已经在谷歌搜索过了,但是没有找到问题所在,请大家帮忙
没有名为“sftpChannel”的bean
表示您还没有sftpChannel
MessageChannel
bean
我认为问题来自@MessagingGateway
bean定义
您需要做的只是声明sftpChannel
bean:
@Bean
public MessageChannel sftpChannel() {
return new DirectChannel();
}
没错,在最新的Spring集成中,这个问题已经得到了解决,MessageChannel
最近根据需要从其名称中得到了解决
没有名为“sftpChannel”的bean
表示您还没有sftpChannel
MessageChannel
bean
我认为问题来自@MessagingGateway
bean定义
您需要做的只是声明sftpChannel
bean:
@Bean
public MessageChannel sftpChannel() {
return new DirectChannel();
}
没错,在最新的Spring集成中,这个问题已经得到了解决,
MessageChannel
最近根据需要从它的名称中得到了解决。Hi@Artem,我添加了“@Bean(name=“sftpChannel”)public MessageChannel sftpChannel(){return new DirectChannel();}`但它仍然是:没有名为“sftpChannel”的bean我的spring集成sftp版本5.0.5好吧,没有这样的版本。我猜可能是4.0.5
。考虑升级到最新的:另外,请分享更多关于错误的堆栈跟踪。还有一个愚蠢的问题:你真的有@enableeintegration
?嗨@Artem,我添加了“@Bean(name=“sftpChannel”)public MessageChannel sftpChannel(){return new DirectChannel();}`但它仍然是:没有名为“sftpChannel”的Bean我的spring integration sftp版本5.0.5,没有这样的版本。我猜可能是4.0.5
。考虑升级到最新的:另外,请分享更多关于错误的堆栈跟踪。还有一个愚蠢的问题:你真的有@使能集成
?
org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'sftpChannel' available
@Bean
public MessageChannel sftpChannel() {
return new DirectChannel();
}