我使用以下代码使用FTP入站适配器进行文件传输,但文件不会被传输。任何关于此的线索都会非常有用。
@Bean
public IntegrationFlow ftpIn()
{
DefaultFtpSessionFactory defSession=new DefaultFtpSessionFactory();
defSession.setUsername("anonymous");
defSession.setPassword("anonymous!!");
defSession.setPort(21);
defSession.setHost("10.47.116.158");
File localDirectory=new File("C:\\FTP_Default");
File remoteDirectory=new File("C:\\FilesFromServer");
return IntegrationFlows.from(Ftp.inboundAdapter(defSession).localDirectory(localDirectory).remoteDirectory("C:\\FilesFromServer")
.autoCreateLocalDirectory(true),
e -> e.poller(Pollers.fixedRate(50)).autoStartup(true))
.channel(this.inputChannel())
.handle(System.out::println).get();
}
@Bean
public DirectChannel inputChannel() {
return new DirectChannel();
}
答案 0 :(得分:0)
上述问题的解决方案是:
@Bean
public IntegrationFlow ftpIn()
{
DefaultFtpSessionFactory defSession=new DefaultFtpSessionFactory();
defSession.setUsername(userId);
defSession.setPassword(password);
defSession.setPort(port);
defSession.setHost(host);
defSession.setClientMode(2);
**String remoteDirectory=DefaultFtpSessionFactory.DEFAULT_REMOTE_WORKING_DIRECTORY;**
File localDirectory=new File("C:\\FilesFromServer");
return IntegrationFlows.from(Ftp.inboundAdapter(defSession).localDirectory(localDirectory).remoteDirectory(remoteDirectory)
.autoCreateLocalDirectory(true),
e -> e.poller(Pollers.fixedRate(50)))
.channel(this.inputChannel())
.handle(m -> System.out.println(m.getPayload())).get();
}
@Bean
public DirectChannel inputChannel() {
return new DirectChannel();
}