(this.applicationContext, bean, beanName));return bean;}private void bind(ConfigurationPropertiesBean.../springframework/boot/context/properties/ConfigurationPropertiesBean.javapublic static ConfigurationPropertiesBean...= null) {bindTarget = bindTarget.withExistingValue(instance);}return new ConfigurationPropertiesBean(...> bindTarget;private final BindMethod bindMethod;//......}ConfigurationPropertiesBean用于代表一个标注了@ConfigurationProperties...> bind(ConfigurationPropertiesBean propertiesBean) {Bindable<?
ConfigurationPropertiesBean.get org/springframework/boot/context/properties/ConfigurationPropertiesBean.java...public static ConfigurationPropertiesBean get(ApplicationContext applicationContext, Object bean, String...ConfigurationPropertiesBean org/springframework/boot/context/properties/ConfigurationPropertiesBean.java...> bindTarget; private final BindMethod bindMethod; //...... } ConfigurationPropertiesBean用于代表一个标注了...> bind(ConfigurationPropertiesBean propertiesBean) { Bindable<?
ConfigurationPropertiesBean,然后调用内部方法bind进行绑定,先看一下ConfigurationPropertiesBean的get方法: public static ConfigurationPropertiesBean...: private static ConfigurationPropertiesBean create(String name, Object instance, Class<?...= null) { bindTarget = bindTarget.withExistingValue(instance); } return new ConfigurationPropertiesBean...言归正传,回到前边调用私有方法bind进行属性绑定的调用: private void bind(ConfigurationPropertiesBean bean) { if (bean == null...> bind(ConfigurationPropertiesBean propertiesBean) { Bindable<?
继续探究postProcessBeforeInitialization方法 我们点开ConfigurationPropertiesBean.get(this.applicationContext, bean..., beanName),发现这样一个方法: public static ConfigurationPropertiesBean get(ApplicationContext applicationContext...(ApplicationContext applicationContext, Object bean, String beanName)是用来返回一个ConfigurationPropertiesBean...> type, Method factory)最终创建了这样一个ConfigurationPropertiesBean。...再看bind方法 现在让我们重回bind(ConfigurationPropertiesBean.get(this.applicationContext, bean, beanName)); if
如果没有带参数的构造器则再通过 setters 注入; 怎么判断是通过 setters 注入还是构造器注入,请看这个类的源码: org.springframework.boot.context.properties.ConfigurationPropertiesBean.BindMethod
spring-boot-2.2.6.RELEASE.jar:2.2.6.RELEASE] 22 at org.springframework.boot.context.properties.ConfigurationPropertiesBean...$BindMethod.forType(ConfigurationPropertiesBean.java:311) ~[spring-boot-2.2.6.RELEASE.jar:2.2.6.RELEASE...spring-boot-2.2.6.RELEASE.jar:2.2.6.RELEASE] 113 at org.springframework.boot.context.properties.ConfigurationPropertiesBean...$BindMethod.forType(ConfigurationPropertiesBean.java:311) ~[spring-boot-2.2.6.RELEASE.jar:2.2.6.RELEASE...ConfigurationPropertiesBindConstructorProvider.java:48) 204 at org.springframework.boot.context.properties.ConfigurationPropertiesBean
ConfigurationBeanFactoryMetadata赞成ConfigurationPropertiesBean。
Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException { bind(ConfigurationPropertiesBean.get
postProcessBeforeInitialization(Object bean, String beanName) throws BeansException { bind(ConfigurationPropertiesBean.get...(this.applicationContext, bean, beanName)); return bean; } private void bind(ConfigurationPropertiesBean...> bind(ConfigurationPropertiesBean propertiesBean) { Bindable<?
领取专属 10元无门槛券
手把手带您无忧上云