6.1.5 Using special property values
When setting properties, you aren’t limited to declaring their values as hardcoded String and numeric values. Instead, you can derive their values from other configuration properties.
For example, suppose (for whatever reason) you want to set a property named greeting.welcome to echo the value of another property named spring.application.name. To achieve this, you could use the ${} placeholder markers when setting greeting.welcome as follows:
greeting:
welcome: ${spring.application.name}You can even embed that placeholder amid other text, as shown here:
greeting:
welcome: You are using ${spring.application.name}As you’ve seen, configuring Spring’s own components with configuration properties makes it easy to inject values into those components’ properties and to fine-tune autoconfiguration. Configuration properties aren’t exclusive to the beans that Spring creates. With a small amount of effort, you can take advantage of configuration properties in your own beans. Let’s see how.
