A bit of context: I'm trying to externalize the paths of my application (log, database, ...), and put everything in a directory APP_HOME. This directory should default to ~/myapp, and should be possible for users to override with a command line switch --home=/usr/local/myapp. At first I tried with:
# In application.properties
app.home=${home:~/myapp}
logging.file=${app.home}/myapp.log
spring.datasource.url=jdbc:h2:${app.home}/database
but it doesn't resolve to the user home directory (at least on my Windows 7), so I tried with:
app.home=${home:#{systemProperties['user.home']}/myapp}
but it isn't interpreted as a SpEL snippet and is left as-is. I think I have to do the wiring inside my Java configuration, but wonder if it's possible to change the system
Comment From: dsyer
You don't need SpEL for that:
app.home=${home:${user.home}/myapp}
would work. I don't think SpEL is such a good idea in properties files (it's not clear what the root context would be).
Comment From: RaffaeleSgarro
Thanks for your reply. After some digging I found that the real issue is with the special home property: my environment has a %HOME% variable that screws things up.
Sorry for opening this issue