将 Spring 框架添加到现有 JSP/EJB 应用程序

发布于 2024-10-08 13:29:23 字数 139 浏览 0 评论 0原文

几年前,我有一个用 JSP 和 EJB 2.1 开发的现有应用程序。现在我想用新功能增强应用程序。有没有办法在同一个旧应用程序中使用 Spring 和 Hibernate 框架来添加新功能,或者我是否需要开发新应用程序以使用最新的框架。

提前致谢。

I had an existing application developed in JSP and EJB 2.1 years ago. Now i want to enhance the application with new features. Is there a way to use Spring and Hibernate frameworks within the same old application for adding new features or do i need to go for developing new application to use latest frameworks.

Thanks in advance.

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

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

发布评论

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

评论(3

深府石板幽径 2024-10-15 13:29:23

首先,为什么要添加Spring?你这样做的目的是什么?要回答这个问题,是的,您可以找到一种方法来慢慢开始将其集成到现有应用程序中,但在我看来,您需要一个很好的理由。

如果您真的想通过这样的重大更改来“现代化”应用程序(并且您有理由),我个人会从一个全新的项目开始,然后将您可以重用的内容导入其中。

随着时间的推移(几乎所有)发生变化的应用程序会变得混乱,并且随着时间的推移会积累大量“垃圾”。最终它们无法维护,无论是因为应用程序中的一些中小企业找到了另一份工作,还是因为它变得太混乱和脆弱。我情不自禁地认为,做这样的事情(添加到现有的应用程序中)只会加速老化过程(您对删除“旧”东西有多大信心,而没有“以防万一”留下它的冲动?) ,趁你还可以的时候,最好把房子打扫干净。除非你说的是一个状态相当好的小应用程序,但根据我的经验,这种情况很少见。

First, why do you want to add Spring? What is your goal in doing so? To answer the question, yes, you could find a way to slowly start integrating it into an existing app, but you'll need a pretty good reason in my opinion.

If you really want to 'modernize' the application with a major change like that (and you have a justification), personally I'd start with a brand new project and just import the stuff you can reuse into that.

Applications that change over time (virtually all) get messy and accumulate a lot of "junk" the older they get. Eventually they're unmaintainable, whether it's because some SME in the app finds another job, or because it just gets too confusing and fragile. I can't help but think doing something like this (adding into an existing app) is just accelerating that aging process (how confident will you be in removing the "old" stuff without the urge to leave it "just in case"?), so much better to clean house while you can. Unless you're talking a small app that's in pretty good shape, but that's rarely the case in my experience.

粉红×色少女 2024-10-15 13:29:23

您可以将 Spring 和 Hibernate 添加到您现有的应用程序中(毕竟,它们只是一堆 jar 文件),尽管我真的不建议这样做。

首先,EJB 2.1 和 Hibernate 会发生冲突,因为 EJB 2.1 没有标准 JPA 并且使用旧的 EJB 查询语言。

为了持久性,我建议使用其中一种或另一种,而不是混合使用。如果您有大量使用 EJB 2.1 编写的数据库访问代码,那么请避免将 Hibernate 引入您的组合中。这将会是一团糟。如果您只使用 JDBC,那么我想 Hibernate 可能是一个不错的选择。

至于Spring,由于它是一个框架,因此将Spring“添加到您的应用程序中”并不是一件小事。春天是巨大的,你应该问问自己会有什么好处。您想使用哪些部件?只是依赖注入? EJB 2.1 中不存在抽象层?不容易。

底线:将 Spring 和 Hibernate 引入到您的应用程序中是可行的,尽管如果不认真考虑,这将是一项混乱、痛苦且耗时的工作,特别是当您的应用程序很大时。

You can add Spring and Hibernate to your existing application (after all, they're just a bunch of jar files), although I wouldn't really recommend doing so.

First of all, EJB 2.1 and Hibernate will clash since EJB 2.1 doesn't have standard JPA and uses the old EJB query language.

For persistence, I'd suggest using one or other and not mixing them. If you have significant amount of database access code written using EJB 2.1, then avoid introducing Hibernate into your mix. It will be a mess. If you're just using JDBC, then I guess Hibernate could be a nice fit.

As for Spring, since it's a framework, it's not really trivial to just "add Spring" to your application. Spring is huge and you should ask yourself what would be the benefits. Which parts do you want to use? Just dependency injection? Abstraction layers that aren't present in EJB 2.1? Not easy.

Bottom line: introducing Spring and Hibernate to your application is doable, although it's gonna be a messy, painful and time consuming endaveour without serious considerations, especially if your application is large.

☆獨立☆ 2024-10-15 13:29:23

感谢您的回复。

我的旧应用程序(JSP+EJB 2.1)是一个很大的应用程序。
我们对系统进行了一些增强。现在我们有2个选择。

  1. 使用规则引擎和最新框架替换旧系统并开发更多模块化系统,以便将来添加新功能/增强功能需要更少的时间来实现。将旧系统迁移到新应用程序花费了近一年的时间。

  2. 使用 Spring、Hibernate、规则引擎等最新框架对现有系统进行增强,并根据时间/预算慢慢将旧内容迁移到新技术平台。 (不确定这在技术上是否有效)。

现在您有了更多信息,那么最好的继续方法是什么。

Thanks for the response.

My old application (JSP+EJB 2.1) is a big one.
We got some enhancements on the system. Now we have 2 choices.

  1. Replace old system and develop more modular system with rules engine and latest frameworks, so that adding new features/enhancements in future takes less time to implement. Nearly it takes a year to migrate the old system to new application.

  2. Add enhancements to the existing system using latest frameworks like spring, hibernate, rules engine etc. and slowly migrate the old stuff into new technology platform depending on time/budget. (Not sure this will work or not technically).

Now you had more info, so what is the best way to proceed.

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