Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Skip Spring placeholder substitution

Tags:

java

spring

I'm using Spring properties placeholders in my application. One of my properties values contains something Spring interprets as a placeholder, but I don't want it:

@Value("${propertyName}")
private String property;

My property is well defined:

propertyName=Welcome ${name}

Without surprise I get an error :

Could not resolve placeholder 'name' in value "Welcome ${name}"

propertyName is something I want to interpret myself, so I don't want ${name} to be resolved by Spring. Is this possible?

like image 803
jaudo Avatar asked Oct 15 '25 16:10

jaudo


1 Answers

You need to escape dollar ($) in that case. So that spring doesn't treat this as a property.

propertyName=Welcome #{'$'}{name}
like image 91
pvpkiran Avatar answered Oct 18 '25 05:10

pvpkiran



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!