spring-boot
spring-boot copied to clipboard
Binding to @ConfigurationProperties on @bean method with a Map does not work
Hi, i use @ConfigurationProperties on @Bean method, part of code as follow:
@Bean
@ConfigurationProperties("xxx.yyy.aa")
public void dealSomething(){
DataA a=DataA.create().build();
}
public class DataA(){
public Map<String,String> properties=new HashMap<String,String>();
public static DataA create(){
return new DataA ();
}
public DataA build(){
// here, why properties is empty map? It is not set to properties map object
String url=properties.get("url");
MutablePropertyValues values=new MutablePropertyValues(properties);
//...
}
}
application.properties
xxx.yyy.aa.url=xxxx
xxx.yyy.aa.user=xxxxx
xxx.yyy.aa.oo=xxx
I want to @ConfigurationProperties on @Bean method with a Map ,it can be work!! please help me,thank you!
Thanks for getting in touch, but it feels like this is a question that would be better suited to Stack Overflow. As mentioned in the guidelines for contributing, we prefer to use GitHub issues only for bugs and enhancements. Feel free to update this issue with a link to the re-posted question (so that other people can find it) or add some more details if you feel this is a genuine bug.