xml - 从 SpEL 表达式中的 .properties 文件访问属性
问题描述
我需要构建一个动态路径,将属性文件中定义的值与 SpEL 表达式的结果相结合,但找不到正确的语法来实现这一点。
我的情况是这样的:
<bean class="org.springframework.context.support.PropertySourcesPlaceholderConfigurer">
<property name="locations">
<list>
<value>classpath:myprop.properties</value>
</list>
</property>
<property name="ignoreUnresolvablePlaceholders" value="false"/>
</bean>
<bean id="fileNameToFSTree"
class="foo.bar.FileNameToFSTree"/>
<int-file:outbound-channel-adapter id="filesOut"
auto-create-directory="true"
directory-expression="${outDir} + @fileNameToFSTree.nameToTree(payload)"
delete-source-files="true"/>
鉴于该myprop.properties
文件包含一个变量outDir
,我想将该变量添加到directory-expression
出站文件中。
显然它会定期评估${outDir}
,但我得到以下异常:
org.springframework.expression.spel.SpelParseException: Expression [/tmp/output + @fileNameToFSTree.nameToTree(payload)] @0: EL1070E: Problem parsing left operand
我在文档或示例中没有发现该案例的痕迹。
有什么提示吗?
解决方案
在发布问题后找到这个答案:
基本上,语法是:
directory-expression="'${outDir}' + @fileNameToFSTree.nameToTree(payload)"
推荐阅读
- jenkins - 在 Jenkins 中触发构建 Github 的 webhook head_commit
- matlab - 我应该如何使用 open_system 通过使用“句柄”而不是 GUI 中的特定 Simulink 文件名来打开 Simulink 模块?
- aws-lambda - 与多个无服务器功能共享数据库是一种好习惯吗?
- kubernetes - 是否有 JMeter GUI 和 CLI 的替代方案可以在没有“kubectl exec”的情况下在 Kubernetes 中执行 JMeter 测试?
- java - JDialog 在 Windows 10 的右侧显示器上无法正确定位,缩放比例为 150%
- featuretools - 运行 dfs 时的 featuretools 进度条
- java - 如何将每个用户链接到他们在 Firebase 中的数据?
- mysql - MySQL 8 获取当前执行的过程名称
- javascript - 如何使使用 Google Javascript Map API 制作的地图加载而不是保持白色
- mysql - 当连接的表可以有一条或多条记录时,如何连接关联表?