recursion - 日志被 WARN 消息污染:“使用递归时文件名模式必须为 '*'”
问题描述
我在 Spring Boot 应用程序中使用 Spring Integration(版本 5.4.4)从 sftp 服务器递归下载文件。为此,我使用带有 mget 命令和正则表达式文件名过滤器的 SFTP 出站网关:
@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 - 文件名使用递归时模式必须是'*'"
不幸的是,我无法解决这个问题 - 你有什么想法吗?
解决方案
远程文件路径的表达式(payload
在您的情况下)必须评估为应该以 . 结尾的内容*
,例如remoteDir/*
. 必须传输树中的所有文件名。只有在那之后,您的文件列表过滤器才会产生影响。
推荐阅读
- php - 特殊字母“š”无法正确显示
- node.js - 在 ExpressJS 设置中没有出现 Favicon
- arrays - 斯威夫特:如何从洗牌数组中获取一项
- android - 如何在每个 Fragment 中拥有单独的 ViewModel 实例并在 Viewmodel 之间共享数据
- c# - C# 跨表单引用值
- regex - 与正则表达式匹配的问题
- python - 使用 numpy 将图像分成通道
- c++ - 仅在我退出应用程序后使用 cout.write() 函数在控制台上打印字符串
- python-3.x - 简单的 Python 代码不起作用(或者和字符串比较)
- python - 如何在类中注入代码并在运行时为类字段赋值?