Java 集成 Play 框架 2.0 和 Spring 框架
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9703714/
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
Integrating Play framework 2.0 and Spring framework
提问by balteo
I have developed a Spring/JPA application: the service, repository and domain layers are nearing completion.
我开发了一个 Spring/JPA 应用程序:服务、存储库和域层即将完成。
The only layer that is missing is the web layer. I am considering using Playframework 2.0 for the web layer but I am not sure whether I can inject/use spring beans in my Playframework 2.0 classes.
该所缺的只是层是网络层。我正在考虑将 Playframework 2.0 用于 web 层,但我不确定是否可以在我的 Playframework 2.0 类中注入/使用 spring bean。
Is this possible? If so how?
这可能吗?如果是这样怎么办?
采纳答案by Will Sargent
You can. Updated for Play 2.5.x:
你可以。为 Play 2.5.x 更新:
回答by alex.p
There's already supportfor the Spring IoC container in Play. It's just a matter of editing the application.conf file as mentioned in the linked to article.
有已经支持在播放Spring IoC容器。这只是编辑 application.conf 文件的问题,如链接到文章中所述。
Ignore the above see comment: it seems that this was dropped in playframework 2.0.
忽略上面看到的评论:这似乎是在 playframework 2.0 中删除的。
回答by Christopher Hunt
Here is a another way of injecting beans using Spring. Standard annotations are used. No plugin is required.
这是使用 Spring 注入 bean 的另一种方法。使用标准注释。不需要插件。
回答by hytrus
Alex.p is right there is support for spring in PlayFramework
Alex.p 是对的,PlayFramework 支持 spring
Have a look here : http://typesafe.com/blog/announcing-play-framework-21-the-high-velocit
看看这里:http: //typesafe.com/blog/annoucing-play-framework-21-the-high-velocit
and on example here : https://github.com/guillaumebort/play20-spring-demo
和这里的例子:https: //github.com/guillaumebort/play20-spring-demo
Cheers
干杯
I just tested it on my project it works but on playframework 2.1 in 2.0 it didn't work.
我刚刚在我的项目中对其进行了测试,但它在 2.0 中的 playframework 2.1 中不起作用。