在游戏表情中添加动态值

时间:2019-07-04 00:50:35

标签: spring-integration spring-el spring-integration-sftp

我有一个具有恒定值的字符串,我想在使用MV网关时将其传递给named_to标头。

我尝试了以下代码片段,并通过在上下文中添加变量,然后将其与#basePath一起使用

@Value("${basePath:/home/}")
String basePath;

.enrichHeaders(h -> h
                        .headerExpression(RENAME_TO, "'${basePath}' + headers[file_remoteFile]")
                        .headerExpression(REMOTE_FILE, "headers[file_remoteFile]")
                        .header(REMOTE_DIRECTORY, "headers[file_remoteDirectory]"))

启动时出现错误。如何在我的application.properties中提供basePath

1 个答案:

答案 0 :(得分:0)

  

@Value("${basePath:/home/}")

     

String basePath;

表示如果没有basePath属性,则将“ / home /”注入变量basePath

您不能像SPeL表达式中那样使用封闭类中的字段,也不能在SpEL中使用属性占位符。您必须在Java中串联字符串。

.headerExpression(RENAME_TO, "'" + this.basePath + "'" + " + headers[file_remoteFile]")
相关问题