2014-07-09 42 views
0

我试图用Spring上传文件,但我面临着我不明白的问题。使用Spring框架的FTP文件传输

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

<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

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

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

+0

我已经添加了缓存会话并切换到最新版本的spring集成,现在我收到了这个错误: org.springframework.beans.factory.xml。 XmlBeanDefinitionStoreException:来自类路径资源[citrus-context.xml]的XML文档中的第553行无效;嵌套异常是org.xml.sax.SAXParseException; systemId:http://www.springframework.org/schema/integration/ftp/spring-integration-ftp.xsd; lineNumber:553; columnNumber:71; src-resolve:无法将名称'integration:smartLifeCycleAttributeGroup'解析为(n)'属性组'组件。 – mlethys

+0

您应该升级所有Spring集成jar并为Spring Nature配置IDE,以便从CLASSPATH而不是Internet解析XSD。自从2.2版本以来''cache-sessions'已被删除。使用最新版本,您应该在目标'sesssionFactory'周围配置'CachingSessionFactory'来实现缓存功能。 –