使用Spring框架进行Ftp文件传输

时间:2014-07-09 09:08:49

标签: ftp spring-integration

我正在尝试使用Spring上传文件,但我遇到了我不明白的问题。

这是我对适配器和会话工厂的定义:

<bean id="ftpClientFactory"
        class="org.springframework.integration.ftp.session.DefaultFtpSessionFactory">
    <property name="host" value="127.0.0.1"/>
    <property name="port" value="21"/>
    <property name="username" value="test"/>
    <property name="password" value="test"/>
    <property name="clientMode" value="0"/>
</bean>

<si:channel id="ftpChannel"/>

<int-ftp:outbound-channel-adapter id="ftpOutbound"
                                  channel="ftpChannel"
                                  remote-directory="/Users/testUser"
                                  session-factory="ftpClientFactory"/>

这是我得到的错误:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'ftpOutbound': Cannot resolve reference to bean 'org.springframework.integration.file.remote.handler.FileTransferringMessageHandler#0' while setting bean property 'handler'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.integration.file.remote.handler.FileTransferringMessageHandler#0': Cannot create inner bean '(inner bean)' of type [org.springframework.integration.file.remote.session.SessionFactoryFactoryBean] while setting constructor argument; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name '(inner bean)': Unsatisfied dependency expressed through constructor argument with index 1 of type [boolean]: Could not convert constructor argument value of type [java.lang.String] to required type [boolean]: Failed to convert value of type 'java.lang.String' to required type 'boolean'; nested exception is java.lang.IllegalArgumentException: Invalid boolean value []

知道我做错了什么吗?谢谢你的建议。

1 个答案:

答案 0 :(得分:1)

您似乎应该将cache-sessions="true"添加到 <int-ftp:outbound-channel-adapter>配置。

但是从另一方面来看,Spring Integration 2.1是非常老的版本,它已经是EOL了。如果您切换到最新版本会更好:http://projects.spring.io/spring-integration