Spring:有还是一个容器?

发布于 2024-11-15 20:56:24 字数 203 浏览 2 评论 0 原文

它如何正确:

“Spring 一般来说是一个容器,它管理对象......”

“Spring 使用/包含一个容器,它管理对象......”

我的意思是,IoC 容器是 Spring 框架的一部分,正确的?或者你可以说,Spring 是一个容器吗?

谢谢:-)

[Spring框架3.0.5]

How is it correct:

"Spring is in general a container, which manages objects..."

or

"Spring uses/contains a container, which manages objects...."

I mean, the IoC Container is PART of the Spring Framework, right? Or could you say, Spring IS a container?

Thanks :-)

[Spring Framework 3.0.5]

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

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

发布评论

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

评论(1

有深☉意 2024-11-22 20:56:24

Spring 是一个遵循控制反转范式的框架。控制反转是一个原则(实现细节并不重要)——“反转”是指您在代码之外的配置中连接 Bean。有很多方法可以做到这一点。一个类比是面向对象编程。面向对象是一种范式,就像 IoC 一样,有很多方法可以实现。就像面向对象一样,有些细节你应该知道,但范式存在于更高的层次。

Spring 是一个框架,因为它包含许多库来让您的生活更轻松。这里细节很重要;您需要知道 JmsTemplate 或 TransactionTemplate 如何工作才能使用它们。

您的问题主要是关于描述 Spring 时使用的最佳词语,这是一个很有价值的问题。现在看这张图片,取自 此处

在此处输入图像描述

首先,高级词语包括FRAMEWORK。应用程序还有一个称为容器的逻辑部分,它被进一步划分为多个组件。容器的文档是 此处。当人们谈论 Spring 时,他们主要会说它是一个框架和一个 IoC 容器,具体取决于他们如何使用它。也许准确地说 Spring 是一个包含 IoC 容器的框架。

重要的是,您可以使用 Spring 框架中与 IoC 无关的部分、仅与 IoC 部分相关的部分,或者两者兼而有之。

Spring is a Framework that follows the Inversion of Control paradigm. Inversion of Control is a principle (the implementation details do not matter) -- the "inversion" is when you wire up your beans outside of the code, in the configuration. There are many ways to do that. An analogy would be Object Oriented programming. Object Oriented is a paradigm, just like IoC, with many ways to do it. Just like with OO, there are details that you should know, but the paradigm exists at a higher level.

Spring is a Framework because it includes a lot of libraries to make your life easier. Here the details matter; you need to know how JmsTemplate or the TransactionTemplate work to use them.

Your question is primarily about the best words to use when describing Spring, which is a valuable question. Now look at this picture, taken from here.

enter image description here

First, the high level words include FRAMEWORK. There is also a logical part of the application called the container, that is further divided into its components. The documentation for the container is here. When people talk about Spring, they primarily say its a framework and an IoC container, depending on how they use it. Perhaps it is accurate to say Spring is a Framework that includes an IoC container.

The important thing is you can use parts of the Spring Framework that have nothing to do with IoC , just the IoC part, or both.

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