Spring 3、Java EE 6
我正在学习 Java EE 6。我已经看到它在此版本的总括规范中取得了多大的进步。 EJB 3.1 比以前的版本更简单、更轻量,而且 CDI 令人惊叹。
我不熟悉 Spring,但我经常读到它提供了一些 Java EE 堆栈所没有的简洁功能。但我现在还了解到 Java EE 已经迎头赶上,并且现在可以与 Spring 完全竞争。
我知道选择两者取决于很多因素,但如果我们只关注功能,比如最新趋势等,哪一个具有领先优势? Spring 3 可以提供一些 Java EE 6 堆栈不能提供的资产吗?
另外,Seam 框架怎么样?据我了解,它类似于 Java EE 6,但还添加了一些内容?
I'm learning Java EE 6. I've seen how much progress it has achieved in this release of the umbrella specification. EJBs 3.1 are far easier and more lightweight than previous versions, and CDI is amazing.
I'm not familiar with Spring, but I often read that it offered some neat features that the Java EE stack didn't. Yet I also read now that Java EE has caught up, and can now fully compete with Spring.
I know that choosing from both depends on many factors, but if we only focus on features, say the latest trends etc. Which one has the leading edge? Can Spring 3 offer some assets The Java EE 6 stack can't?
Also, what about Seam framework? From what I read it's like Java EE 6 but with some additions?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
随着时间的推移,JavaEE 在功能方面确实迎头赶上。
但我多次偶然发现的一个因素是我长期以来更喜欢 Spring 的主要原因 - JavaEE 服务器和实现存在缺陷且对开发人员不友好。这听起来像是咆哮,但即使是最好的 JavaEE 6 - CDI (Weld impl) 也有神秘的异常消息,并且给开发人员带来了困难 (参见此处)。更不用说应用程序服务器了——充满了非常丑陋的错误(我在使用 JBoss 5 的 3 小时内设法找到了大约 5 个错误)
Spring 对我来说更有吸引力的另一件事是可以在很短的时间内添加功能。正如我在评论中指出的,统一缓存抽象和会话处理将在 Spring 的下一个版本中添加,这是在上一个版本之后的几个月。在 JavaEE 中,您必须等待很多时间(至少对于标准解决方案),
但 JavaEE 并不是那么黑。许多问题都有解决方法或得到及时解决。最终,这是个人喜好的问题。
顺便说一句,Spring 的产品组合同时充满了副项目,它们添加了许多特定的功能/功能集。请注意,其中许多也可以与 JavaEE 一起使用,但设计得与 spring 完美契合:
这只是额外的,JavaEE 也有额外的,但它们更通用 -目的(就我所看到的图片而言),除了 Seam 之外,它专门针对提供 CDI 所遗漏的内容。
最后有一个非常重要的注释。将 spring 与 JavaEE 进行比较是不正确的。我更愿意将 Spring 与 CDI+EJB+应用服务器进行比较。 JavaEE 的其余部分可以与 spring 一起使用,而且经常如此。 JAX-WS、JAXB、甚至 JSF 都与 spring 很好地配合并且经常使用。
Over time, JavaEE indeed caught up in terms of features.
But one factor, that I've stumbled upon many times, is the main reason I've been preferring spring for a long time - JavaEE servers and implementations are buggy and developer-unfriendly. This may sound like a rant, but even the best of JavaEE 6 - CDI (Weld impl) has cryptic exception messages and is giving developers a hard time (see here). Not to mention application servers - full of really ugly bugs (I managed to find around 5 bugs for 3 hours working with JBoss 5)
Another thing that makes spring more attractive for me is that features can be added in small timeframes. As I noted in my comment, unified cache abstraction, and conversation handling will be added in the next release of spring, which is a couple of months after the previous version. In JavaEE you'd have to wait a lot of time (for a standard solution at least)
But it's not that black with JavaEE. Many of the problems have workarounds or get fixed in a timely manner. And ultimately, it's a matter of personal preference.
By the way, spring's portfolio was filled with side-projects in the meantime, which add a lot of specific features/features sets. Note that many of them can be used with JavaEE as well, but are designed to fit perfectly with spring:
This is just extras, and JavaEE also has extras, but they are more general-purpose (as far as I see the picture), apart from Seam, which is specifically targeted at providing what CDI misses.
One very important note to conclude with. Comparing spring to JavaEE is incorrect. I'd prefer to compare Spring to CDI+EJB+Application server. The rest of JavaEE can be used together with spring, and it often is. JAX-WS, JAXB, even JSF fit nicely with spring and are often used.