In Spring property (or yaml) files we can reference other properties using the ${..} syntax.
For example:
external.host=https://api.external.com external.productService=${external.host}/product-service external.orderService=${external.host}/order-service
If we now access the external.productService property (e.g. by using the @Value annotation) we will get the value https://api.external.com/product-service.
For example:
@Value("${external.productService}") private String productServiceUrl; // https://api.external.com/product-service
This way we can avoid duplication of commonly used values in property and yaml files.
Leave a reply