0

I am trying to understand something about the following application.properties syntax in spring

some-api:
  url: ${variable.url:http://localhost:8080}

I know that to get the value of the above we use (for example)

@Value("${some-api.url}")
private String url;

what's the point of declaring ${variable.url:VALUE} when I reference it with some-api.url ? where do you use this ?

also can you call this value in pom.xml ?

Ranked Bronze
  • 71
  • 1
  • 9

1 Answers1

1

In your example properties file you are referring another property, like this is how your application.yml must be looking

variable:
  url: http://host

some-api:
  url: ${variable.url:http://localhost:8080}

and vaue after : is the default value when variable.url is not defined.

also can you call this value in pom.xml ?

No, you need some maven plugin which can read your properties file in order to do that.

sagarr
  • 1,152
  • 1
  • 9
  • 16