我想创建@Bean ExampleProperties.java并希望在application.yaml中自动获取键/值,例如:
@ConfigurationProperties("server")
public class ExampleProperties {
private String context-path; //this would be a mistake, cause you could not have "-" in parameter name,
}
如何创建参数等于application.yml ??
中的键答案 0 :(得分:0)
@ConfigurationProperties("server")
public class ExampleProperties {
private String contextPath;
}
答案 1 :(得分:0)
如果你和我一样,你的财产是这样的:
my-config-map.key
那么你想要:
@ConfigurationProperties(prefix = "my-config-map")
public class Prop {
private String key;
// getter/setter
}