Playframework:如何在不同项目之间共享模型? [英] Playframework : How to share models between different projects?

查看:118
本文介绍了Playframework:如何在不同项目之间共享模型?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想与其他一些项目分享我的模型,他们使用相同的模型,但不是相同的字段映射和约束。我想知道是否有方法从模型中提取注释并使用xml配置?或其他方式来实现这一目标?



注意:我正在使用 play 1.3

解决方案

上周我正在分析类似的东西。



为每个可重复使用的模型生成一个库(jar),由注释或由 orm.xml


  1. META-INF 文件夹(但不是 presistence.xml )上的c $ c> 。

  2. 在web应用程序项目中,引用所需的模型库并使用 persistence.xml定义 entityManager / code> on META-INF

请参阅 JPA规范 6.2持久性单元打包 / p>

其他参考资料:



祝你好运!


I want to share my Models with some other projects, they use the same models but not the same field mappings and constraints. I wonder if there is way to extract annotations from models and use xml configuration instead ? Or other way to achieve this ?

NOTE : I'm using play 1.3.

解决方案

Last week I were analyzing something like that.

A way to archive this is:

  1. generate a library (jar) for each reusable models, defined by annotations or by orm.xml files on META-INF folder (but not presistence.xml).
  2. In web application project, reference required model libraries and define the entityManager using a persistence.xml on META-INF.

For more information see the JPA spec, 6.2 Persistence Unit Packaging

Other references:

Good luck!

这篇关于Playframework:如何在不同项目之间共享模型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆