依赖注入如何在Spring中工作? [英] How does dependency injection work in Spring?

查看:104
本文介绍了依赖注入如何在Spring中工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道spring如何依赖注入。我想要使​​用低级逻辑。

I want to know how spring does dependency injection. I want the low level logic used.

我想知道如何注入对象引用到构造函数或setter方法,是通过Reflection还是一些字节代码级别。

I want to know how the object references are injected to the constructors or setter methods, is it through Reflection or some byte code level.

推荐答案

从XML读取依赖项的配置,注释或Java DSL(JavaConfig)。然后,Spring DI引擎使用Java反射API基于配置中的元数据连接依赖项。

Configuration of dependencies are read from XML, annotations or Java DSL (JavaConfig). Then Spring DI engine wires the dependencies based on the metadata from the configuration using the Java reflection API.

这篇关于依赖注入如何在Spring中工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆