【发布时间】:2021-08-06 14:12:16
【问题描述】:
我正在使用带有 Camel 框架的 Spring Boot。
我需要保存一个属性,例如:
output.file=file://C:/Users/bfrisco/Desktop/output?fileName=${headers.fileName}
我需要这个原始字符串。我不希望 Spring 尝试解决 ${headers.fileName},我想要的正是我输入的文本。启动我的应用程序时,我会收到此错误:
无法解析占位符“headers.fileName”
这个值是动态的,会在运行时改变。 Camel 将以不同于 Spring 的方式解释这个属性。我一直无法找到一种方法来阻止 spring 在启动时尝试解释这一点。
我有这个可行的解决方法,但它并不理想,我觉得有更好的方法:
# Inserted a ! between so Spring does not interpret it
output.file=file://C:/Users/bfrisco/Desktop/output?fileName=$!{headers.fileName}
@Value("${output.file}")
private String outputFile;
@PostConstruct
public void init() {
outputFile = outputFile.replaceAll("!", "");
}
有没有办法解决这个问题,而无需在每个需要使用这些值的类中实现此解决方法?
【问题讨论】:
标签: java spring spring-boot apache-camel spring-camel