SFTP 适配器

Spring Integration 提供对通过 SFTP 进行文件传输操作的支持。

安全文件传输协议(SFTP)是一种网络协议,允许您通过任何可靠的流在互联网上的两台计算机之间传输文件。

SFTP 协议需要一个安全通道,例如 SSH,并在整个 SFTP 会话期间对客户端身份可见。

Spring Integration 通过提供三种客户端端点来支持通过 SFTP 发送和接收文件:入站通道适配器、出站通道适配器和出站网关。它还提供了便捷的命名空间配置来定义这些客户端组件。

从 6.0 版本开始,已过时的 JCraft JSch 客户端已被现代的 Apache MINA SSHD 框架取代。这导致框架组件发生许多重大变更。然而,在大多数情况下,这种迁移隐藏在 Spring Integration API 之后。最剧烈的变化发生在 DefaultSftpSessionFactory 上,它现在基于 org.apache.sshd.client.SshClient,并公开了它的一些配置属性。

您需要在项目中包含此依赖项

  • Maven

  • Gradle

<dependency>
    <groupId>org.springframework.integration</groupId>
    <artifactId>spring-integration-sftp</artifactId>
    <version>6.4.4</version>
</dependency>
compile "org.springframework.integration:spring-integration-sftp:6.4.4"

要在 XML 配置中包含 SFTP 命名空间,请在根元素上包含以下属性

xmlns:int-sftp="http://www.springframework.org/schema/integration/sftp"
xsi:schemaLocation="http://www.springframework.org/schema/integration/sftp
    https://www.springframework.org/schema/integration/sftp/spring-integration-sftp.xsd"