3

在 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)
4

1 回答 1

0

每个 FTP 网关只能处理一种方法。

您需要为每个声明一个,然后...

@MessagingGateway
public interface MyGateway {

     @Gateway(requestChannel = "toFtpGetChannel")
     void sendToFtpGet(...);

     @Gateway(requestChannel = "toFtpPutChannel")
     void sendToFtpPut(...);

    ...

}
于 2017-08-18T13:03:24.103 回答