Java Web 框架:Play 与 Spring MVC 有何不同?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3576836/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Web Frameworks: How is Play different from Spring MVC?
提问by Play vs. Spring
The Play Frameworkoffers the following quick overview, but with the exception of the Groovy template engine (which you can get in Spring MVC if you want), Spring seems to offer all the same features and more...
该游戏框架提供了以下简要概述,但与Groovy的模板引擎(您可以在Spring MVC,如果你想获得)外,春天似乎都提供相同的功能和更多...
Fix the bug and hit reload!Edit your Java files, save, refresh your browser and see the results immediately! No need to compile, deploy or restart the server. Spring does this, which can get annoying.
Stateless modelPlay is a real "Share nothing" system. Ready for REST, it is easily scaled by running multiple instances of the same application on several servers. Typical Spring applications have a stateless application tier; it's not purely RESTful unless you want to be, but Spring is "ready for REST".
Efficient template systemA clean template system based on Groovy as an expression language. It provides template inheritence, includes and tags. Spring uses Java, but Groovy is an option too.
Resolve errors quicklyWhen an error occurs, play shows you the source code and the exact line containing the problem. Even in templates. Spring does this as well.
All you need to create a cool web applicationProvides integration with Hibernate, OpenID, Memcached... And a plugin system. Spring integrates with everything and more.
Pure JavaCode with Java, use any Java library and develop with your preferred IDE. Integrates nicely with eclipse or netbeans. Spring is pure Java as well.
Really fastStarts fast and runs fast! Subjective, but Spring is pretty quick.
修复错误并点击重新加载!编辑您的 Java 文件、保存、刷新浏览器并立即查看结果!无需编译、部署或重启服务器。Spring 会这样做,这会很烦人。
无状态模型Play 是一个真正的“无共享”系统。为 REST 做好准备,可以通过在多台服务器上运行同一应用程序的多个实例来轻松扩展。典型的 Spring 应用程序有一个无状态的应用程序层;除非您愿意,否则它不是纯粹的 RESTful,但 Spring 已“为 REST 做好准备”。
高效的模板系统基于 Groovy 作为表达语言的干净模板系统。它提供模板继承、包含和标签。Spring 使用 Java,但 Groovy 也是一种选择。
快速解决错误发生错误时,play 会向您显示源代码和包含问题的确切行。即使在模板中。Spring 也是这样做的。
创建一个很酷的 Web 应用程序所需的一切提供与 Hibernate、OpenID、Memcached 的集成......以及一个插件系统。Spring 与一切以及更多内容集成。
使用 Java编写纯 Java代码,使用任何 Java 库并使用您喜欢的 IDE 进行开发。与 eclipse 或 netbeans 很好地集成。Spring 也是纯 Java 的。
真快启动快,运行快!主观,但 Spring 很快。
So what does the Play Framework actually do differently than Spring MVC?
In a nutshell what can Spring do that Play framework cannot (and vice-versa)?
那么 Play 框架实际上与 Spring MVC 有什么不同呢?
简而言之,Spring 可以做什么而 Play 框架不能(反之亦然)?
回答by irreputable
I find the "pure Java" claim on either side very funny.
我发现两边的“纯 Java”声明都非常有趣。
Of course, it's unrealistic for a project to use absolutely nothing but java. Still, a "pure Java" label should have some standards, I don't think either framework qualifies.
当然,一个项目只用java是不现实的。尽管如此,“纯 Java”标签应该有一些标准,我认为这两个框架都不符合条件。
Play actually modifies the semantics of Java language. That is all right as long as it's clearly specified. If you do some byte code manipulation, just be honest about it. Usually it's done by AOP-ish trick, instance methods are decorated with additional behaviors, their manifest behaviors - these written in the code, are usually preserved. This is not too hard to accept, we can pretend our code are subclassed by the framework and our methods are overridden with additional behavior.
Play 实际上修改了 Java 语言的语义。只要明确规定就可以。如果您进行一些字节码操作,请诚实对待。通常它是由 AOP-ish 技巧完成的,实例方法用额外的行为装饰,它们的明显行为 - 这些写在代码中,通常被保留。这并不难接受,我们可以假设我们的代码是由框架子类化的,并且我们的方法被其他行为覆盖。
In Play, one static method calling another static method in the same class can have magical effects, and the behavior is nothing like a method call. That is a huge problem, if a Java programmer can no longer be certain what a static method call is.
在 Play 中,一个静态方法调用同一个类中的另一个静态方法可以产生神奇的效果,其行为与方法调用完全不同。如果 Java 程序员不再能确定静态方法调用是什么,那将是一个大问题。
Spring - well, their Java part is still pure Java all right. But it's so magical(from java's POV), and depends so heavily on a heavy framework, calling Spring "pure Java", is like calling a burger "pure vege" if we overlook the meat. The meat is the best part!
Spring - 好吧,他们的 Java 部分仍然是纯 Java。但是它太神奇了(来自 java 的 POV),并且在很大程度上依赖于一个沉重的框架,称 Spring 为“纯 Java”,如果我们忽略肉,则就像将汉堡称为“纯蔬菜”一样。肉是最好的部分!