Is spring boot allow to use parametred keys using YAML ?
Example of parametred key:
myapp.configured.key: This is your email > {0} And this is your name > {1}
And in my Java class i want to do some thing like this:
@Inject
private Environment env;//import org.springframework.core.env.Environment;
String email = "[email protected]"
String name = "User Name";
String key=env.getProperty("myapp.configured.key", email, name);
System.out.println(key);
And the out put will be like this :
This is your email > [email protected] And this is your name > User Name
If your email and name are also configuration keys, you can refer to them in your message (but it's a bit weird)
myapp.configured.email: [email protected]
myapp.configured.name: John Smith
myapp.configured.key: This is your email > ${myapp.configured.email} And this is your name > ${myapp.configured.name}
The Environment has no such API and as a Spring Boot user you shouldn't even touch that stuff (check @ConfigurationProperties for type safe binding of configuration).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With