小编Ang*_*mad的帖子

如何从自定义java组件中的上下文属性占位符标记获取属性

我有定义的Mule配置

<context:property-placeholder location="classpath:/mule-sw.properties"/>
Run Code Online (Sandbox Code Playgroud)

我还有一个Java自定义组件类,它在我的一个字段上使用@Lookup注释

@Lookup("file-path")
private String path;
Run Code Online (Sandbox Code Playgroud)

考虑到我的"mule-sw.properties"是这样的

file-path=C:/hello.txt
Run Code Online (Sandbox Code Playgroud)

在我启动Mule App之后,我总是得到Deploy Exception

org.mule.api.expression.RequiredValueException: "Required object not found in registry of Type "class java.lang.String" with name "file-path" on object "class component.CustomComponent"
Run Code Online (Sandbox Code Playgroud)

我还尝试使用@Lookup("$ {file-path}")更改@Lookup("文件路径")但没有成功.

谁能给我一个更好的解决方案?任何帮助都非常感谢.

谢谢

spring mule

1
推荐指数
1
解决办法
4689
查看次数

标签 统计

mule ×1

spring ×1