...。所谓依赖注入,就是由外部容器在运行时动态地将依赖的对象注入到组件之中。具体的依赖注入方式又包括如下三种典型的形式。 构造器注入(Constructor Injection):IoC容器会智能地选择选择和调用适合的构造函数以创建依赖的对象。
基于138个网页-相关网页
这称为构造器注入。
OpenEJB还将支持构造器注入,从而使得容器可以在运行时提供各种类和对象。
OpenEJB will also support constructor injection, which enables the container to provide various classes and objects at run time.
毫无疑问,这些setter是框架所需的样板代码,如果不使用构造器注入也能避免这一点岂不美哉?
Again, these setters are framework induced boilerplate code. Wouldn’t it be nice if they could be avoided without the need to use Constructor injection everywhere?
应用推荐