I'm using Spring Boot with the Camel framework.
I need to save a property such as:
output.file=file://C:/Users/bfrisco/Desktop/output?fileName=${headers.fileName}
I need this raw string. I do not want Spring to try and resolve ${headers.fileName}
, I want exactly the text I have entered. When starting my application, I will receive this error:
Could not resolve placeholder 'headers.fileName'
This value is dynamic and will change during runtime. Camel will be interpreting this property, in a different way than Spring does. I have been unable to find a way to prevent spring from attempting to interpret this at boot-time.
I have this workaround that is working, but it's not ideal and I feel like there's a better way:
# 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("!", "");
}
Is there a way to resolve this without implementing this workaround in each class where using these values is necessary?
You can escape it with
output.file=file://C:/Users/bfrisco/Desktop/output?fileName=#{'$'}{headers.fileName}