EJB3 带来了哪些功能以及 EJB3 如何与 Spring 框架结合?

发布于 2024-10-09 04:27:18 字数 1539 浏览 0 评论 0原文

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

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

发布评论

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

评论(3

巴黎盛开的樱花 2024-10-16 04:27:18

EJB 是一项相当古老的技术(大约 1999 年)。然而,直到该标准第三版发布之前,它的使用都非常不方便。 Spring 作为一种明智的替代方案而变得流行,它提供了一些相同的核心功能(声明式事务和安全性)以及一些新功能(依赖注入、AOP)。它还与许多其他技术(例如 Hibernate)很好地集成。

然而,从 V3.0 开始,EJB(或者更确切地说,EJB 所属的整个 Java EE 平台)进行了重大修改,变得更加易于使用。此外,各种框架(包括Spring)流行的许多功能都被制定为官方标准并添加到Java EE中。

目前,Java EE 平台在受欢迎程度方面比 Spring 获得了很大的优势,因为它们在易用性和功能方面都差不多,而且 Java EE 的优势在于基于开放标准,具有多种实现方式大多数组成部分。与此同时,在我看来,Spring 在与其他框架集成(这曾经是它的优势)方面在跟上最先进的技术方面遇到了问题。

EJB is a quite old technology (ca. 1999). However, until Version 3 of the standard, it was horribly inconvenient to use. Spring became popular as a sane alternative that offered some of the same core features (declarative transactions and security) as well as some new ones (dependency injection, AOP). It also integrated well with many other technologies such as Hibernate.

However, starting with V3.0, EJBs (or rather, the whole Java EE platform of which EJBs are a part) got a major overhaul and became much easier to use. Additionally, a lot of features made popular by various frameworks (including Spring) were made into official standards and added to Java EE.

Right now, the Java EE platform is gaining a lot of ground vs. Spring in terms of popularity, since they're about even in ease of use and features, and Java EE has the advantage of being based on open standards with multiple implementations for most component. At the same time, it seems to me Spring is having problems keeping up with the state of the art when it comes to integrating with other frameworks (which used to be its strength).

奶茶白久 2024-10-16 04:27:18

我想说唯一的主要区别是 Java EE 5 和 6 是一个标准。它采用了 Spring 和其他人的想法,并从中创建了一个标准。与旧的 EJB 相比,EJB3 日夜不停。所有 EJB 都是 POJO,并且依赖项由容器注入。所有这些不同的界面以及从主界面手动创建实例的情况都消失了。如果您已经使用 Spring 做了很多工作,那么您可能最多需要几个小时来学习。如果您正在开发 Web 应用程序,您还需要了解 JSF。

我从未使用旧的 EJB 做过真正的应用程序,因为这太痛苦了。我一直使用 EJB3,因为它毫不费力。如果您想尝试最新的一切,请获取 glassfish 的副本,我认为它仍然是唯一经过 Java EE 6 认证的服务器。

I would say the only major difference is Java EE 5 and 6 are a standard. It's taken the ideas of Spring and others and created a standard out of them. Compared to the old EJBs, EJB3 is night and day. All your EJBs are POJOs and dependencies are injected by the container. Gone are all those different interfaces and creating instances manually from the home interface. It will take you maybe couple hours at most to learn if you've already done a lot with Spring. You'll also want to look at JSF if you're doing web applications.

I never did a real application with the old EJBs because it was such a pain. EJB3 I use all the time as it's effortless. If you want to try the newest everything, get a copy of glassfish which I think is still the only Java EE 6 certified server.

相守太难 2024-10-16 04:27:18

在依赖注入和 MVC 架构方面,Spring 在灵活性和易用性方面优于 Java EE 5,尽管正如其他人所说,Java EE 5 (EJB3) 比以前版本的 Java EE/ EJB。借助 Java EE 6,我相信 Java EE 在使用新 CDI (JSR-299) 实现的 DI 和使用 JSF 2.0 的 MVC 方面都领先于 Spring。

Oracle 在线教程很初级,但却是学习 Java EE 的良好起点。 Reza Rahman 的系列文章是了解 Java EE 6 中 DI 的绝佳资源 http://www.theserverside.com/news/1373391/Dependency-Injection-in-Java-EE-6-Part-1

In terms of both dependency injection and MVC architectures, Spring had the edge over Java EE 5 in terms of flexibility and ease of use, although as others have said, Java EE 5 (EJB3) was a huge improvement over previous versions of Java EE/EJB. With Java EE 6 I believe Java EE has leapt ahead of Spring in both DI w/ the new CDI (JSR-299) implementation, and in MVC w/ JSF 2.0.

The Oracle online tutorials are rudimentary, but a good starting point for learning Java EE. An excellent resource for learning about DI in Java EE 6 is Reza Rahman's series of articles http://www.theserverside.com/news/1373391/Dependency-Injection-in-Java-EE-6-Part-1

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