Spring Integration 提供了可用于创建 FTP(或 FTPS)会话的工厂。
默认工厂
从版本 3.0 开始,默认情况下不再缓存会话。 请参阅 FTP 会话缓存。 |
在配置 FTP 适配器之前,必须配置 FTP 会话工厂。
您可以使用常规 Bean 定义配置 FTP 会话工厂,其中实现类为 。
以下示例显示了基本配置:o.s.i.ftp.session.DefaultFtpSessionFactory
<bean id="ftpClientFactory"
class="org.springframework.integration.ftp.session.DefaultFtpSessionFactory">
<property name="host" value="localhost"/>
<property name="port" value="22"/>
<property name="username" value="kermit"/>
<property name="password" value="frog"/>
<property name="clientMode" value="0"/>
<property name="fileType" value="2"/>
<property name="bufferSize" value="100000"/>
</bean>
对于 FTPS 连接,您可以改用。o.s.i.ftp.session.DefaultFtpsSessionFactory
以下示例显示了一个完整的配置:
<bean id="ftpClientFactory"
class="org.springframework.integration.ftp.session.DefaultFtpsSessionFactory">
<property name="host" value="localhost"/>
<property name="port" value="22"/>
<property name="username" value="oleg"/>
<property name="password" value="password"/>
<property name="clientMode" value="1"/>
<property name="fileType" value="2"/>
<property name="useClientMode" value="true"/>
<property name="cipherSuites" value="a,b.c"/>
<property name="keyManager" ref="keyManager"/>
<property name="protocol" value="SSL"/>
<property name="trustManager" ref="trustManager"/>
<property name="prot" value="P"/>
<property name="needClientAuth" value="true"/>
<property name="authValue" value="oleg"/>
<property name="sessionCreation" value="true"/>
<property name="protocols" value="SSL, TLS"/>
<property name="implicit" value="true"/>
</bean>
如果您遇到连接问题,并且想要跟踪会话创建以及查看轮询了哪些会话,则可以通过将记录器设置为级别(例如,)来启用会话跟踪。TRACE log4j.category.org.springframework.integration.file=TRACE |
现在,您只需要将这些会话工厂注入到适配器中即可。 适配器使用的协议(FTP 或 FTPS)取决于已注入适配器的会话工厂的类型。
为 FTP 或 FTPS 会话工厂提供值的更实用方法是使用 Spring 的属性占位符支持(参见 docs.spring.io/spring/docs/current/spring-framework-reference/core.html#beans-factory-placeholderconfigurer)。 |
从版本 3.0 开始,默认情况下不再缓存会话。 请参阅 FTP 会话缓存。 |
如果您遇到连接问题,并且想要跟踪会话创建以及查看轮询了哪些会话,则可以通过将记录器设置为级别(例如,)来启用会话跟踪。TRACE log4j.category.org.springframework.integration.file=TRACE |
为 FTP 或 FTPS 会话工厂提供值的更实用方法是使用 Spring 的属性占位符支持(参见 docs.spring.io/spring/docs/current/spring-framework-reference/core.html#beans-factory-placeholderconfigurer)。 |