Spring vs Jboss
对于企业Web应用程序来说,Spring与Jboss的优缺点是什么?
这是一个很好的问题。有些人在这里错误地指出这是一个苹果与桔子的比较,即Jboss是一个容器,而Spring只是一个框架,如Struts。但是,这有点令人困惑的原因是JBoss和Spring都从其原始的简单起源中进行了很大的扩展,因此彼此之间越来越靠近。理解JBoss的一种简单方法是,该名称是原始的" EJBoss",并且旨在用作开源J2EE应用程序服务器,因此与tomcat相比,它在充当EJB容器方面具有优势,因此可以与WebSphere竞争和其他专有应用程序服务器。
Spring是一个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.
尽管Spring可以很好地运行,并且可以(大部分)与JBoss共存,但是它不需要成熟的EJB容器,但是可以在tomcat中轻松运行。 Spring的整个设计目标是基于轻量级设计的思想,POJO的使用以及对重型容器的需求,这与EJB非常相反,因此似乎与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.
因此,您必须决定要使用的两个系统的哪些部分以及要遵循的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,
要了解有关各种Java标准的最新信息,请查看对Spring 5的反馈要求。您可以了解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).
如前所述,但让我重申一下这一点。 JBoss是一个应用程序服务器。一些Java应用程序服务器包括
- 网络圈
- 玻璃鱼
- 老板
Spring是一个框架。 MVC是一个相当大的框架,提供了很多功能,但对我而言,主要功能之一是。 MVC是一种设计模式,您可以从Contoller中将View的Model与模型分开。该模型是数据的表示形式。这可以由数据库或XML文件之类的东西来支持。视图是用于查看模型的视图。它可以是Web前端,也可以是Windows应用程序。用户将与视图进行交互。用户将表达他们对模型更新的愿望。这就是控制器的所在。我们使用contoller告诉模型进行更新。并且由于视图是基于模型的,因此视图也将得到更新。简而言之,这过于简化了。您可以查看的其他MVC框架是Struts。
就像我之前说的,Spring提供了其他功能,例如
- 安全框架
- 控制反转
- 依赖注入
这是我的意见:
Spring代表Java EE的所有优点,而JBoss代表所有的缺点。
好吧...那做得不太好(不是我以为会的)。我只是说我永远不会选择JBoss来托管任何应用程序。它是如此笨重且重量级,并且没有做任何特别出色的事情。我喜欢Spring,因为它不那么单调和笨拙。诚然,Spring不是应用程序容器,但是它可以用于构建托管应用程序所需的大部分基础结构-您只需将其插入容器中,其余的由Spring处理。
JBoss是一个容器,spring是在容器内部运行的容器。您正在将苹果与橙子进行比较。
在JBoss上运行的应用程序是整体式的(一个JVM进程可以完成所有工作),在其中您将需要一个垂直/水平的集群来扩展规模,在这里可以通过调整spring的使用来实现微服务架构。
由于java6和CDI(请看@inject)是错误的,
春天不再是唯一的春天了。
在15年前使用EJB2(甚至EJB3)时就适用
但是如今,CDI代码在websphere,weblogic,jboss,glassfish等任何所需的应用服务器中进行管理。