简体   繁体   English

集成Play framework 2.0和Spring框架

[英]Integrating Play framework 2.0 and Spring framework

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 . 唯一缺少的是Web图层 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? 如果是这样的话?

You can. 您可以。 Updated for Play 2.5.x: 已针对Play 2.5.x进行了更新:

https://github.com/remithieblin/play-spring-loader https://github.com/remithieblin/play-spring-loader

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/announcing-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上它没有用。

Here is a another way of injecting beans using Spring. 这是使用Spring注入bean的另一种方法。 Standard annotations are used. 使用标准注释。 No plugin is required. 不需要插件。

https://github.com/huntc/play-spring https://github.com/huntc/play-spring

There's already support for the Spring IoC container in Play. 在Play中已经支持 Spring IoC容器。 It's just a matter of editing the application.conf file as mentioned in the linked to article. 只需编辑链接到文章中提到的application.conf文件即可。

Ignore the above see comment: it seems that this was dropped in playframework 2.0. 忽略上面看到的评论:似乎这在playframework 2.0中被删除了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM