Spring boot轻松绑定

时间:2015-12-11 23:21:09

标签: spring spring-boot environment-variables spring-integration properties-file

我试图理解Spring启动中的轻松绑定 我看过https://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-external-config.html#boot-features-external-config-relaxed-binding 但我想我错过了一些东西 如果我有一个包含abc = 123的属性文件a.properties并且我想使用env变量来覆盖它,那么我相信我应该能够添加A_B_C = 456并且它应该可以工作,但它似乎没有做那。 我只是完全错过了什么

修改

我想真正的问题是,我可以使用带有PropertyPlaceholderConfigurer的RelaxedDataBinder进行宽松的绑定吗?

1 个答案:

答案 0 :(得分:0)

So after researching and chatting with individuals this is not directly possible. The simplest solution to get this moving forward, I believe, is to create an annotated bean in the spring-boot app that defines the properties and uses @ConfigurationProperties to then initialize the values. This should use the relaxed bindings at this point. I can then use this bean instead of property placeholders to build the spring integration beans.

Thanks to @dsyer for the suggestion.