Spring properties that depend on other properties

Spring can combine properties

myDir=/path/to/mydir 
myFile=${myDir}/myfile.txt

You can also use a default value without defining your myFile in the properties at first:

Properties file

myDir=/path/to/mydir

In class:

@Value("#{myFile:${myDir}/myfile.txt}")
private String myFileName;

Leave a Comment