简体   繁体   中英

Wiring properties file with spring - expanding environment variables

I have a .properties file that I"m reading with a Spring @Component,

@Value("${webapp.external_data_source_root_path}")
private String mExternalDataSourceRootPath;

The .properties file has:

webapp.external_data_source_root_path=[user.home]\/my_path\/

What i'm trying to do is to have it replace [user.home] with the system environment variable value for user.home. I tried changing brackets to curly braces, adding '$', etc, but it doesn't ever seem to expand. Is there a way to do this?

Apparently what I need is:

webapp.destination_data_root_path=${user.home}\/my_path\/

I thought I had tried the ${zzz} pattern, but perhaps I had a typo.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM