javaspringproperties-file

Java properties file. Using part of a value to create another value (key-value)


I know that by using the ${} we can use the value of another key.

what if we want to use part of that value? for example, ignore the first 10 chars and use this value.

or using regular expressions for more complex stuff.

can this be done using only properties.file?

tried to find a kind of substr for this but I was able only to find ${}


Solution

  • You seem to need to use Spring Expression Language (SpEL).

    The expression could be something like:

    "#{'${prop1}'.substring(1,3)}"