本文介绍了任何“玩"的经验;java web开发框架?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

我刚刚偶然发现了以下新的 java web 框架:Play

I've just stumbled upon the following new java web framework: Play

http://www.playframework.org/

http://www.playframework.org/documentation/1.0/home

拥有如此惊人的功能列表,我很惊讶我以前从未听说过它......

with such a stunning list of features, I'm pretty much surprised I haven't heard of it before...

听起来像是 java web 开发的乐土……

Sounds like the java web development promised land...

有人试过吗?有什么真正的经验吗?你觉得值得研究吗?

has anybody tried it? any real experience with it? do you think it's worth studying it?

推荐答案

我同意 Jason 的观点,Play 可能会被证明比 Grails 更好.我有四个 Grails 项目(之前有两个 Tapestry 项目和一个 Wicket 项目),接下来我会认真考虑 Play.

I agree with Jason that Play might just prove to be better than Grails. With four Grails projects under my belt (preceded by two Tapestry projects and one Wicket project), I'm seriously looking at Play next.

我认为 Grails 的一个很酷的地方是一切都是 Groovy".也就是说,您使用 Groovy 编写所有内容(HTML 和 CSS 除外)——域、控制器、服务、页面模板 (GSP)、标签库、Hibernate API (GORM)、单元测试 (GUnit) 和构建脚本 (甘特).您甚至可以在 Groovy 中编写 shell 脚本.因此,能够再次使用一种语言对应用程序的所有方面进行编码似乎是一种早就应该进行的简化——回想起用 C++ 或 Delphi 等单一语言编写桌面应用程序的日子.但是,我了解到一种尺寸并不适合所有人.

One of the things I thought was cool about Grails is that "everything's Groovy." That is, you use Groovy to write everything (except the HTML and the CSS) -- domains, controllers, services, page templates (GSP), tag libraries, Hibernate API (GORM), unit tests (GUnit), and build scripts (GANT). You can even write shell scripts in Groovy. So, being able to code all aspects of an app using a single language again seemed like a simplification that was long overdue -- hearkening back to the days of writing desktop apps in a single language like C++ or Delphi. However, I've learned that one size does not fit all here.

首先,对 Groovy 的 IDE 支持不是很好.IntelliJ 做得最好,但由于 Groovy 是动态的,它只能做到这一点.重构工具不能(不能)捕获所有内容,因此您不能 100% 信任它们.这意味着您必须特别警惕单元测试.再说一次,因为 Grails 非常依赖在运行时发生的动态魔法",所以 Grails 中的单元测试必须依赖一个广泛的模拟层来模拟它,而这个模拟层很古怪.第三个问题是,您正在编写的许多所谓的 Groovy 代码实际上是领域特定语言 (DSL) 代码.(长话短说,DSL 是 Groovy 的简写,它利用了在 Groovy 中和许多语法是可选的这一事实.)Grails 对各种配置、URL 映射等使用不同的 DSL,而且它是不一致的.例如,您指定 log4j 设置的方式与指定数据源的方式完全不同,也与 Groovy 所基于的纯 Java 不同.因此,无论如何,一切都是 Groovy"的承诺落空了.

For one, the IDE support for Groovy isn't great. IntelliJ does the best job, but with Groovy being dynamic, it can only go so far. The refactoring tools do not (cannot) catch everything, so you can't trust them 100%. This means you have to be especially vigilant with unit testing. Here again, because Grails relies so much on dynamic "magic" that happens at runtime, the unit testing in Grails must rely on an extensive mocking layer to emulate it, and that mocking layer is quirky. A third issue is that much of the so-called Groovy code that you're writing is actually domain-specific-language (DSL) code. (To make a long story short, DSLs are short-hand Groovy, taking advantage of the fact that in Groovy and lot of the syntax is optional.) Grails uses different DSLs for various configurations, URL mapping, etc. and it is inconsistent. How you specify log4j settings, for example, looks nothing like how you specify the data sources, and neither looks like the pure Java upon which Groovy is based. So, the promise of "everything's Groovy" falls apart anyway.

既然如此,我就知道 Play 团队的来源了.

That being the case, I see where the Play team is coming from.

  1. 为域、控制器、服务和 JUnit 回归常规 Java 是有意义的.强类型意味着 IDE 可以可靠地帮助进行智能感知、代码导航、重构等(因此,如果您对 Eclipse 感到满意,则无需为 IntelliJ 付费.)必须编写更详细的代码才能现在,重新获得强大的工具支持对我来说似乎很划算.走着瞧.

  1. Going back to regular Java for the domains, controllers, services, and JUnits makes sense. Strong typing means the IDE can reliably help with inteli-sense, code navigation, refactoring, etc. (And thus you don't need to pay for IntelliJ if you're happy with Eclipse.) Having to write more verbose code in order to gain back strong tool support seems like a good deal to me right now. We'll see.

我喜欢我仍然可以在页面模板中使用 Groovy.不过,恐怕我最终可能会在模板中放入更多的代码.

I like that I still get to use Groovy in the page templates. I'm afraid I may end up putting more code in the templates than I should, though.

我没有使用 JPA 的经验,但它似乎与 GORM 为我所做的非常接近,所以这很酷.

I have no experience with JPA, but it seems like it's pretty close to what GORM does for me, so that's cool.

Grails 中的 Spring IOC 支持是完全透明的,而 Play 的支持似乎很少;但是,我认为 IOC 被过度使用了,我非常愿意在我真正需要的极少数情况下手动编写 Spring XML 映射.(我的一个悬而未决的问题是我假设 JPA 具有事务支持,这就是为什么 Play 不需要像 Grails 那样需要 Spring 的原因,不是吗?)

The Spring IOC support in Grails is completely transparent whereas Play's support seems minimal; however, I think that IOC is way overused and I'm perfectly willing to hand code a Spring XML mapping on the rare occasion that I really need one. (One of my open questions is that I'm assuming that JPA has transaction support which is why Play doesn't need Spring for that like Grails does, no?)

我从来都不是 Python 的粉丝,所以当我读到 Play 使用 Python 作为其构建脚本时,我感到畏缩.但我同意 Grails 的 GANT 脚本运行速度很慢.另外,我发现,虽然 GANT 是对 XML ANT 的巨大改进,但仍然很难理解 ANT 概念.Grails GANT 脚本非常复杂.所以,我会以开放的心态进入它.

I've never been a fan of Python, so I cringed when I read that Play uses Python for its build scripts. But I agree that Grails' GANT scripts run pretty slow. Plus I find that, while GANT is a huge improvement over XML ANT, it's still hard to wrap your head around the ANT concepts. The Grails GANT scripts are pretty convoluted. So, I'll go in to it with an open mind.

Play应用程序模块"模型听起来就像 Grails 的插件"模型,所以这很酷.

The Play "application module" model sounds to be just like Grails' "plugin" model, so that's cool.

到目前为止,我对 Play 文档印象深刻.我有大量的问题要问,但其中一半得到了立即回答.

I'm quite impressed with the Play documentation that I've read so far. I had a huge number of questions going in, but half of them were answered right off the bat.

稍后我会在深入研究时再次报告.

I'll report back again later as I dive deeper in.

这篇关于任何“玩"的经验;java web开发框架?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-06 22:20