0

I have a properties file in JAVA as follows:

base_url = test/url

api_url = ${base_url}/api/url

Now, whenever I try to read property "api_url", I get the value as: "${base_url}/api/url", but what I am looking for is to get "test/url/api/url".

I am using Environment class to read the property file. I using spring 4 with java based configurations.

Note: I tried looking for a solution, but only relevant link I found was using properties within the properties file, and I am not really looking for the work-around suggesting in the solution.

Ankur
  • 892
  • 6
  • 11

2 Answers2

0

If you are using Spring 4, you can try PropertySourcesPlaceholderConfigurer, that should resolve the nested properties

user699848
  • 109
  • 7
0

Try reading the properties like this

@Value("${base_url}") private String baseUrl;
@Value("${api_url}") private String apiUrl;