依赖注入设计模式

发布于 2024-10-02 05:10:06 字数 230 浏览 0 评论 0原文

可能的重复:
什么是依赖注入?

Spring 使用依赖注入模式。有人可以展示这种模式的简单示例吗? 我听说还有另一种模式称为服务定位器,哪个更好?

Possible Duplicate:
What is dependency injection?

Spring uses dependency injection pattern. Can someone show a simple example of this pattern?
I heard there is another pattern called service locator, which one is better?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

微暖i 2024-10-09 05:10:06

服务定位器 是一种 J2EE“核心模式”习惯用法。

在我们辩论之前,让我们先定义一下“更好”,好吗?

在我看来,他们并不是真正的竞争对手。并非所有依赖关系都发生在网络上。 Spring 可以进行远程处理和代理,但这并不是所有依赖项的总和。

Service locator is a J2EE "Core Patterns" idiom.

Let's define "better" before we debate it, shall we?

They aren't really competitors, IMO. Not every dependency happens over a network. Spring can do remoting and proxying, but that's not the sum of all dependencies.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文