Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow SpEL in application.properties #1672

Closed
RaffaeleSgarro opened this issue Oct 8, 2014 · 2 comments
Closed

Allow SpEL in application.properties #1672

RaffaeleSgarro opened this issue Oct 8, 2014 · 2 comments

Comments

@RaffaeleSgarro
Copy link

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

@dsyer
Copy link
Member

dsyer commented Oct 9, 2014

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).

@dsyer dsyer added the status: waiting-for-feedback We need additional information before we can continue label Oct 9, 2014
@RaffaeleSgarro
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants