I found the issue. I am building with Maven. The spring-boot-starter-parent
has resource filtering on by default for application.properties
:
<!-- Turn on filtering by default for application properties -->
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
<includes>
<include>**/application.yml</include>
<include>**/application.properties</include>
</includes>
</resource>
<resource>
<directory>src/main/resources</directory>
<excludes>
<exclude>**/application.yml</exclude>
<exclude>**/application.properties</exclude>
</excludes>
</resource>
</resources>
It seems that ${user.dir}
is also something that Maven will replace. If I looked at the application.properties
in my target/classes
, it was indeed replaced.
To fix, I needed to do the following:
First tell Maven that you want escape filtering:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.6</version>
<configuration>
<escapeString>\</escapeString>
</configuration>
</plugin>
Then change the application.properties
file to:
installationDirectory=\${user.dir}/install
After this, everything works fine.