在 Spring integration ftp doc之后,我设法通过 java config 方式将文件发送到 ftp 服务器:
@MessagingGateway
public interface MyGateway {
@Gateway(requestChannel = "toFtpChannel")
void sendToFtp(File file);
}
ss
public static void main(String[] args) {
ConfigurableApplicationContext context =
new SpringApplicationBuilder(FtpJavaApplication.class)
.web(false)
.run(args);
MyGateway gateway = context.getBean(MyGateway.class);
// sending file to ftp server
gateway.sendToFtp(new File("/foo/bar.txt"));
}
在我看来,上面的代码使用自定义方法“sendToFtp()”将文件发送到目标 ftp 服务器。我的问题是如何在 MyGateway 接口中添加其他方法来实现操作?
ls (list files)
get (retrieve file)
mget (retrieve file(s))
rm (remove file(s))
mv (move/rename file)
put (send file)
mput (send multiple files)