不过,像Guice的作者一样,我更喜欢构造函数注入。
However, I prefer constructor injection, as do Guice's authors. Here's a quick analysis of the three styles.
构造函数注入利用构造函数判断要返回的具体对象类型。
Constructor injection USES a constructor to determine what type of concrete object to return.
根据Guice的最佳实践指南,构造函数注入是询问依赖项的首选方式。
According to the Guice best practices guide, constructor injection is the preferred way to ask for your dependencies.
应用推荐