如何以类似 Ruby on Rails 的方式开发 Java Web 应用程序?

发布于 2024-10-02 09:33:30 字数 325 浏览 1 评论 0原文

我们有一个需要在 Java 应用程序服务器中运行的应用程序。我必须开发一个网络应用程序来配合它。我已经开始阅读有关 Ruby on Rails 的内容,并且我真的很喜欢这种方法:MVC、约定优于配置、为您处理的大量内容。

我可能正在做一个不可能实现的梦想,但是有没有以类似方式工作的 Java Web 应用程序开发框架?

直接的JSP很惨,因为逻辑和表示是混合在一起的。简单的模板系统(例如 Velocity 和 Freemarker)不执行数据库操作。我对春天了解不多。

这里的每个人都了解 Java,并且在下一个发布周期之前我们没有时间学习全新的语言和库,否则我会认真地投入 RoR。

We've got an app that needs to run in a Java app server. I've got to develop a webapp to go with it. I've started reading about Ruby on Rails, and I really like the approach: MVC, convention over configuration, tons of stuff taken care of for you.

I may be dreaming the impossible dream, but are there any Java webapp development frameworks out there that work in a similar way?

Straight JSP is miserable, because logic and presentation are mixed. Simple template systems, like Velocity and Freemarker don't do the database stuff. I don't know much about Spring.

Everybody here knows Java, and we don't have time before the next release cycle to learn an entirely new language and library, else I'd plunge into RoR in a serious way.

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

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

发布评论

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

评论(2

黑白记忆 2024-10-09 09:33:30

完全不是不可能。它已经完成了。

以下是一些 Java 等效项:

都是SpringSource的产品。如果您认真对待 Java Web 开发,我强烈建议您查看它们。

Grails 实际上受到 Rails 的启发,因此得名,因此您会发现两者之间的功能和范例有许多相似之处,包括 MVC、约定优于配置和代码生成。因此,如果您希望直接使用 Java 进行类似 Rails 的开发,我强烈推荐 Grails。我应该指出,Grails 比 Rails 有更多的功能,我认为 Rails 应该采用其中一些功能。一个例子是 Grails 提供了一个服务层来处理所有业务逻辑。您可以轻松地在 Rails 中实现服务层,但我们都喜欢它的便利性,并且因为 Grails 包含它,所以它更方便。我曾经在 Rails 和 Grails 之间徘徊,这两个框架都是很棒的框架。

请记住,您也可以通过 JRuby 使用 Java 进行 Rails 开发,这也是一个不错的选择。您可以获得 Ruby 语言 (v. 1.8) 的所有功能,以及在 Ruby 代码中集成和使用 Java 库的能力。

SpringRoo 是 SpringSource 的新代码生成器框架,因此您可以将其与 Spring 框架一起使用来帮助敏捷/快速的应用程序开发。

Grails 实际上是构建在 Spring 框架和 Groovy 之上的。 Groovy 是 Java 的衍生语言,它看起来更像是一种脚本语言,并且提供了您在 Ruby 和 Python 等语言中看到的所有元/动态编程优点。然而,Groovy 也允许您编写 Java 代码,因此不需要学习它,至少不需要完全学习。

Not impossible at all. It's already been done.

Here are a few Java-equivalents:

All are products of SpringSource. If you're getting serious about Java web development, I highly recommend you check them out.

Grails was actually inspired by Rails, hence the name, so you'll see many similarities in features and paradigms between the two, including MVC, convention-over-configuration, and code generation. So if you're looking to get right into Rails-like development in Java, I highly recommend Grails. I should note that Grails has more features than Rails, some of which I think Rails should adopt. An example is Grails provides a service layer to handle all business logic. You could easily implement a service layer in Rails, but its convenience we all love, and because Grails includes it, it is more convenient. I've hopped between Rails and Grails once upon a time, both great frameworks.

Keep in mind that you can do Rails development with Java as well, via JRuby, which is not a bad option either. You get all the features of the Ruby language (v. 1.8), along with the ability to integrate and use Java libraries within your Ruby code.

SpringRoo is SpringSource's new code generator framework, so you can use it with the Spring framework to aid in agile/rapid application development.

Grails is actually built on-top of the Spring framework and Groovy. Groovy is Java-derivative which looks more like a scripting language and provides all the meta/dynamic programming goodness that you see in languages such as Ruby and Python. However, Groovy allows you to write Java code as well, so there's no need to learn it, not entirely at least.

束缚m 2024-10-09 09:33:30

仔细查看 Play 框架。我认为这是目前开发 Java Web 应用程序的最佳方式。当然是最快的。没有部署周期。保存代码并刷新浏览器。

它配备了 Hibernate 和一系列可简化开发过程的增强功能。完全基于 REST 且无状态。

添加 jQuery 感觉就像网络天堂。

Have a good look at the the Play Framework. I think that it's the best way to develop Java web applications at the moment. Certainly the quickest. There is no deploy cycle. Save the code and refresh the browser.

It comes with Hibernate and a host of enhanced functionality that streamlines the development process. Totally REST based and stateless.

Add in jQuery and it feels like web heaven.

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