0

我已经使用 sftp:inbound-streaming-channel-adapter 和 zookeeper。但它给了我异常:java.lang.ClassCastException: com.jcraft.jsch.ChannelSftp$LsEntry 不能转换为 java.io.File。我正在使用以下代码

<int-sftp:inbound-streaming-channel-adapter
    id="sftpAdapter" channel="receiveChannel"
    session-factory="cachingSessionFactory" 
    remote-file-separator="/" remote-directory-expression="'${ftpServerLoc}'" filter="compositeFilter"
    auto-startup="true">
    <int:poller fixed-rate="${pollarInterval}"
        max-messages-per-poll="1" />
</int-sftp:inbound-streaming-channel-adapter>

  <beans:bean id="compositeFilter"
    class="org.springframework.integration.file.filters.CompositeFileListFilter">
    <beans:constructor-arg>
        <beans:list>
             <beans:bean
                class="org.springframework.integration.file.filters.RegexPatternFileListFilter">
                 <beans:constructor-arg value="^.*\.(dat|DAT)$" />

            </beans:bean>
            <beans:bean
                class="org.springframework.integration.sftp.filters.SftpPersistentAcceptOnceFileListFilter">
                <beans:constructor-arg name="store"
                    ref="metadataStore" />
                <beans:constructor-arg value="" />
            </beans:bean>
        </beans:list>
    </beans:constructor-arg>
</beans:bean>
4

1 回答 1

1

org.springframework.integration.file.filters.RegexPatternFileListFilter应该org.springframework.integration.sftp.filters.SftpRegexPatternFileListFilter是。

您申请的那个java.io.File;sftp 版本适用于LsEntry(Jsch 对远程文件的表示)。

于 2017-11-08T13:25:05.623 回答