日志被 WARN 消息污染:"File name pattern must be '*' when using recursion"

The log is polluted by WARN messages: "File name pattern must be '*' when using recursion"

我在 Spring 引导应用程序中使用 Spring 集成(版本 5.4.4)从 sftp 服务器递归下载文件。为此,我将 SFTP 出站网关与 mget 命令和正则表达式文件名过滤器一起使用:

@Bean
public IntegrationFlow jsonFilesReadingFlow() {
    String JSON_FILE_REGEX = "...";
    return IntegrationFlows
            .from("sftp_server")
            .handle(Sftp
                    .outboundGateway(sftpSessionFactory(), Command.MGET, "payload")
                    .options(Option.RECURSIVE)
                    .regexFileNameFilter(JSON_FILE_REGEX)
                    .filter(new SftpPersistentAcceptOnceFileListFilter(new SimpleMetadataStore(), "Downloaded_json_file:"))
                    .autoCreateLocalDirectory(true)
                    .localDirectoryExpression("'/${catalina.base}/webapps/app/WEB-INF/classes/temporaryJsonFilesDirectory'")
                    .localFilenameExpression("#remoteFileName.replaceFirst('sftpSource', 'localTarget')"))
            .channel("downloadJsonFileOutputChannel")
            .get();
}

不幸的是,每次在应用程序日志中检查 sftp 服务器时,都会生成一个条目:“[WARN] 2021-07-06 08:56:21 [scheduling-1] org.springframework.core.log.LogAccessor - 文件使用递归时名称模式必须为“*”“

screenshot - application log

不幸的是,我无法解决这个问题 - 你有什么想法吗?

远程文件路径的表达式(在您的情况下为 payload)必须求值为应该以 * 结尾的内容,例如remoteDir/*。必须传输树中的所有文件名。只有在那之后你的文件列表过滤器才会有影响。

请参阅文档中的说明:https://docs.spring.io/spring-integration/docs/current/reference/html/sftp.html#using-the-mget-command