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.3.5</version>
</dependency>
compile "org.springframework.integration:spring-integration-sftp:6.3.5"

若要在您的 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"