spring自动装配构造函数

284 阅读1分钟

"autowire constructor" (with constructor arguments by type) behavior.Also applied if explicit constructor argument values are specified,matching all remaining arguments with beans from the bean factory.

This corresponds to constructor injection: In this mode, a Springbean factory is able to host components that expect constructor-baseddependency resolution. “自动装配构造函数”(构造函数参数按类型)行为。如果指定了显式构造函数参数值,也可以应用,将所有剩余的参数与来自bean工厂的bean匹配。这对应于构造函数注入:在这种模式下,一个Springbean factory能够托管期望基于构造器的组件依赖性解析。org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory#autowireConstructororg.springframework.beans.factory.support.ConstructorResolver#autowireConstructor

之前用BeanPostProcessor的方式处理 file 现在可以替换成这种

file

本文由博客群发一文多发等运营工具平台 OpenWrite 发布