0
我有一个属性文件,其中包含要装入我的程序中使用的路径值。使用Mule中的Spring表达式语言加载属性文件中的值
我在我的XML
<flow doc:name="Flow1" name="Flow1">
<http:inbound-endpoint doc:description="This endpoint receives an HTTP message."
doc:name="HTTP" exchange-pattern="request-response" host="localhost"
port="8081" contentType="text/html" />
<custom-transformer class="com.test.app.mule.ReadFile" doc:name="Java">
<spring:property name="path" value="${key.path1}" />
</custom-transformer>
以下,并在我的Java代码如下(从指定的路径从属性加载一个文件文件)
public class ReadFile extends AbstractMessageTransformer {
private String path;
public String getPath() {
return path;
}
public void setPath(String path) {
this.path = path;
}
/**
* loads the content of the file specified in the parameter
*
* @param filename
* the name of the file
* @return the content of the file
*
*
*/
public String readFile(String filename, String filePath) {
File file1 = new File(path, filePath);
这工作正常,但我想知道是否有任何方法来修改我必须允许使用@value注释
private @Value("${key.path1") String path;
并摆脱setters和getters?
骡子这样做似乎并不好玩。
在春天吗?这非常模糊,没有任何链接为这个问题提供了帮助。 – gio10245
你要做的是通过注释来访问属性。我知道的方法是在Mule上配置上下文占位符,然后通过@Value注入属性。我会找到一个例子在这里发布。 –