简体   繁体   English

春季注射类型之间的差异

[英]Difference between types of injection in Spring

Spring中的Bean注入和依赖注入之间有什么区别,还是相同的?

因为在我们的上下文中依赖项是bean,所以可以说它们是相同的。

Any dependency that is managed by Spring is called a Spring Bean. 由Spring管理的任何依赖项都称为Spring Bean。 When you register a type in Spring, when it is used as a dependency in other objects, it is injected by Spring. 当您在Spring中注册类型时,将其用作其他对象的依赖项时,它将由Spring注入。

On the other hand, Dependency Injection doesn't need a container like Spring. 另一方面,依赖注入不需要像Spring这样的容器。 When you have a method that takes arguments, that argument is a dependency, which is a form of dependency injection instead of hard code the value of the argument in your method. 当您有一个接受参数的方法时,该参数就是一个依赖关系,这是依赖关系注入的一种形式,而不是硬编码方法中参数的值。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM