I want to create @Bean ExampleProperties.java and want to automatically get key/value in application.yaml, for example:
@ConfigurationProperties("server")
public class ExampleProperties {
private String context-path; //this would be a mistake, cause you could not have "-" in parameter name,
}
How to create a parameter equals to the key in application.yml??
According to Spring documentation property with dash would be represented in java as
@ConfigurationProperties("server")
public class ExampleProperties {
private String contextPath;
}
If you are like me and your property looks like this :
my-config-map.key
Then you want:
@ConfigurationProperties(prefix = "my-config-map")
public class Prop {
private String key;
// getter/setter
}
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