Spring vs Jboss
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/627839/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Spring vs Jboss
提问by flybywire
What are the advantages and disadvantages for Spring vs. Jboss for an enterprise web application.
对于企业 Web 应用程序,Spring 与 Jboss 的优缺点是什么。
采纳答案by uriDium
As already said, but let me just restate the point. JBoss is an application server. Some Java application servers include
正如已经说过的,但让我重申这一点。JBoss 是一个应用服务器。一些 Java 应用服务器包括
- Websphere
- Glassfish
- JBoss
- 网络领域
- 玻璃鱼
- 老板
Spring is a framework. A rather large framework which offers quite a bit but for me one of the main features is MVC. MVC is a design pattern where you separate your Model from View from your Contoller. The model is the representation of the data. This can be backed by things like database or XML files. The view is what is used to view the model. This can be either web frontend or a windows application. The user will interact with the view. The user will express their desire for the model to be updated. This is where the controller comes in. We use the contoller to tell the model to update. And because the view is based on the model the view then gets updated too. This is over simplifying but in a nutshell. Other MVC framework that you can look at is Struts.
Spring是一个框架。一个相当大的框架,它提供了很多,但对我来说,主要功能之一是 MVC。MVC 是一种设计模式,您可以将模型与视图与控制器分开。模型是数据的表示。这可以由数据库或 XML 文件之类的东西支持。视图是用来查看模型的。这可以是 Web 前端或 Windows 应用程序。用户将与视图交互。用户将表达他们希望更新模型。这就是控制器的用武之地。我们使用控制器来告诉模型更新。因为视图是基于模型的,所以视图也会更新。这过于简化,但简而言之。您可以查看的其他 MVC 框架是 Struts。
Like I said earlier there are other features that Spring offers such as
就像我之前说的,Spring 还提供了其他功能,例如
- Security framework
- Inversion Of Control
- Dependency Injection
- 安全框架
- 控制反转
- 依赖注入
回答by michaelok
This is a good question. Some have incorrectly stated here that this is an apples to oranges comparison, i.e. Jboss is a container, and Spring is simply a framework, like Struts. However, the reason this is a bit confusing is that both JBoss and Spring have expanded considerably from their original, simple origins, and are thus moving closer towards each other. One easy way to understand JBoss is that the name was original "EJBoss", and it was intended on being an open-source J2EE application server, so it had the advantage over tomcat over serving as an EJB container, and thus could compete with WebSphere and other proprietary application servers.
这是一个很好的问题。有些人在这里错误地指出这是一个苹果与橘子的比较,即 Jboss 是一个容器,而 Spring 只是一个框架,就像 Struts。然而,这有点令人困惑的原因是 JBoss 和 Spring 都从它们最初的、简单的起源开始有了很大的扩展,因此彼此越来越接近。一个简单的理解 JBoss 的方法是,这个名字最初是“EJBoss”,它的目的是成为一个开源的 J2EE 应用服务器,所以它比作为 EJB 容器的 tomcat 有优势,因此可以与 WebSphere 竞争和其他专有应用程序服务器。
And Spring was an IoC framework (now referred to as "Dependency Injection"), essentially a factory for objects so that you can follow a more "loosely coupled" design.
Spring 是一个 IoC 框架(现在称为“依赖注入”),本质上是一个对象工厂,以便您可以遵循更“松散耦合”的设计。
However, with their popularity, both products expanded. For example, JBoss now has it's own IoC container: JBoss IoC
然而,随着它们的流行,这两种产品都得到了扩展。例如,JBoss 现在拥有自己的 IoC 容器: JBoss IoC
JBoss provides its own lightweight IoC container called: JBoss Microcontainer. JBoss Microcontainer is a lightweight, Inversion of Control/Dependency Injection container similar in concept to Spring, Pico Container, and Plexus.
JBoss 提供了自己的轻量级 IoC 容器,称为:JBoss Microcontainer。JBoss 微容器是一个轻量级的、控制反转/依赖注入容器,在概念上类似于 Spring、Pico Container 和 Plexus。
And while Spring can run perfectly well, coexisting (mostly) happily with JBoss, it doesn't need a full-blown EJB container, it can run easily in tomcat. The whole design goal of Spring was based on the idea of lightweight design, and the use of POJOs, and the lack of requirement for a heavy-weight container, which was very contrary to EJBs, and thus would seem at odds with JBoss.
虽然 Spring 可以完美运行,与 JBoss 共存(大部分)愉快,但它不需要成熟的 EJB 容器,它可以在 tomcat 中轻松运行。Spring 的整个设计目标是基于轻量级设计的思想,使用 POJO,并且没有对重量级容器的要求,这与 EJB 非常相反,因此看起来与 JBoss 不一致。
Rod Johnsonhas pointed out that there's no reason you can't run Spring in JBoss:
Rod Johnson指出没有理由不能在 JBoss 中运行 Spring:
Spring is designed to work in any application server (or outside an application server); using Spring does not mean ignoring what the server may have to offer. It just provides greater choice in a lot of cases.
Spring 被设计用于任何应用服务器(或应用服务器之外);使用 Spring 并不意味着忽略服务器可能必须提供的内容。它只是在很多情况下提供了更多的选择。
So what you have to decide is what parts of the two systems you want to use, and what Java standards you want to adhere to. According to this article, on JBoss and Spring, which covers how well they adhere to standards, it does seem, depending on which technology you select, you are picking a side, as this seems to be a pretty contentious battle.
因此,您必须决定要使用这两个系统的哪些部分,以及要遵守哪些 Java 标准。根据这篇文章,关于JBoss 和 Spring,其中涵盖了它们对标准的遵守程度,看起来确实取决于您选择的技术,您选择了一方,因为这似乎是一场非常有争议的战斗。
What comes next is anything but detente, as JBoss and Spring Source battle over everything from XML to integration to tools to eventually virtualization, itself....its a healthy competition,
[snip]
Only time will tell, but i think that this battle only makes things better for developers, more choices rather than .Net, and more innovation around Java, it will be a tough test for JBoss, but one that they can handle if execution is flawless, otherwise, look for Spring Source to drive a wedge between perceived and real advantages of JEE 6...sooner, rather than later, portability of applications will have to be demonstrated in order to counter the proprietary models, and that has not happened,
接下来的事情绝不是缓和,因为 JBoss 和 Spring Source 在从 XML 到集成到工具再到最终虚拟化的所有方面都在争夺,它本身......这是一场健康的竞争,
[剪辑]
只有时间会证明一切,但我认为这场战斗只会让开发人员的事情变得更好,更多的选择而不是 .Net,以及围绕 Java 的更多创新,这对 JBoss 来说将是一个艰难的考验,但如果执行完美,他们可以应对,否则,寻找 Spring Source 来在 JEE 6 的感知优势和实际优势之间形成楔子……迟早,必须证明应用程序的可移植性以对抗专有模型,而这并没有发生,
For a more up-to-date look at adherence to the various Java standards, take a look the request for feedback on Spring 5. You can get an idea of the constraints the Spring designers face, while also highlighting the fact that, for the Spring market, it is important to ensure Spring supports the various EE servers:
有关遵守各种 Java 标准的最新信息,请查看有关 Spring 5 的反馈请求。您可以了解 Spring 设计人员面临的约束,同时还强调了一个事实,即对于 Spring 市场,确保 Spring 支持各种 EE 服务器非常重要:
We intend to softly upgrade the EE baseline as well. Now, this is a bit tricky since we effectively have individual requirements here - and we need to consider the enterprise adoption levels in production environments:
We'll definitely raise to Servlet 3.0+ (from our present Servlet 2.5 runtime compatibility) but no higher since we'd like Spring 5 applications to run on EE 6 baselined servers still. See my previous blog post for a discussion on why this is unavoidable, given the market situation with Java EE 7 and the multitude of servers which is still based on the Servlet 3.0 API. [snip] It's just a shame that we have to keep supporting the 2002-era JMS 1.1 API… We'd like to raise to JPA 2.1+ and Bean Validation 1.1+ but our hands seem to be tied: TomEE 1.7 and JBoss EAP 6.4 have hard JPA 2.0 and Bean Validation 1.0 APIs in them, and WebLogic 12.1.3 has JPA 2.1 but no Bean Validation 1.1 API (despite them being related).
我们也打算软升级 EE 基线。现在,这有点棘手,因为我们在这里实际上有个人需求 -我们需要考虑生产环境中的企业采用水平:
我们肯定会提升到 Servlet 3.0+(从我们目前的 Servlet 2.5 运行时兼容性)但不会更高,因为我们希望 Spring 5 应用程序仍然在 EE 6 基线服务器上运行。考虑到 Java EE 7 的市场情况和仍然基于 Servlet 3.0 API 的众多服务器,请参阅我之前的博客文章,讨论为什么这是不可避免的。[snip] 很遗憾我们必须继续支持 2002 时代的 JMS 1.1 API……我们想提升到 JPA 2.1+ 和 Bean Validation 1.1+,但我们的手似乎被束缚了:TomEE 1.7 和 JBoss EAP 6.4其中包含硬 JPA 2.0 和 Bean Validation 1.0 API,而 WebLogic 12.1.3 具有 JPA 2.1 但没有 Bean Validation 1.1 API(尽管它们相关)。
回答by Andy White
Here's my opinion:
这是我的意见:
Spring represents all that is good in Java EE, whereas JBoss represents all that is bad.
Spring 代表 Java EE 中的所有优点,而 JBoss 代表所有缺点。
Well... that didn't go over so well (not that I thought it would). I'm just saying that I would never choose JBoss to host any application. It's just so clunky and heavyweight, and does not do anything particularly well. I like Spring because it feels less monolithic and clunky. Granted, Spring is not an application container, but it can be used to build up most of the infrastructure you need to host an app - you just have to plug it into a container, and Spring handles the rest.
嗯……事情并没有那么顺利(不是我想的那样)。我只是说我永远不会选择 JBoss 来托管任何应用程序。它是如此笨重和重量级,并且没有做任何特别好的事情。我喜欢 Spring,因为它感觉不那么单一和笨重。诚然,Spring 不是应用程序容器,但它可用于构建托管应用程序所需的大部分基础设施——您只需将其插入容器,其余部分由 Spring 处理。
回答by mkoryak
JBoss is a container, spring is what runs inside the container. You are comparing apples to oranges.
JBoss 是一个容器,spring 是运行在容器内的东西。您正在将苹果与橙子进行比较。
回答by Srinivas Kothuri
Applications run on JBoss as monolithic (one JVM process does everything) where in you will need a vertical/horizontal cluster to scale , where as use of spring can be adjusted ti implement micro services architecture as well.
应用程序在 JBoss 上作为单体运行(一个 JVM 进程完成所有工作),其中您需要一个垂直/水平集群来扩展,其中 Spring 的使用也可以调整以实现微服务架构。
回答by Rémi
Since java6 and CDI (look at @inject) your opinion it's false, spring is not the only one anymore. Was true 15 years ago with EJB2 (and even EJB3) but today CDI code is managed in websphere, weblogic,jboss,glassfish,... whatever app server you want.
由于 java6 和 CDI(看看@inject)你的意见是错误的,spring 不再是唯一的了。15 年前使用 EJB2(甚至 EJB3)确实如此,但今天 CDI 代码在 websphere、weblogic、jboss、glassfish 中管理,...任何你想要的应用程序服务器。

