Playframework:如何在不同项目之间共享模型? [英] Playframework : How to share models between different projects?
问题描述
我想与其他一些项目分享我的模型,他们使用相同的模型,但不是相同的字段映射和约束。我想知道是否有方法从模型中提取注释并使用xml配置?或其他方式来实现这一目标?
注意:我正在使用 play 1.3
。
上周我正在分析类似的东西。
为每个可重复使用的模型生成一个库(jar),由注释或由 orm.xml $定义。
-
META-INF
文件夹(但不是presistence.xml
)上的c $ c> 。 - 在web应用程序项目中,引用所需的模型库并使用
persistence.xml定义
entityManager
/ code> onMETA-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:
- generate a library (jar) for each reusable models, defined by annotations or by
orm.xml
files onMETA-INF
folder (but notpresistence.xml
). - In web application project, reference required model libraries and define the
entityManager
using apersistence.xml
onMETA-INF
.
For more information see the JPA spec, 6.2 Persistence Unit Packaging
Other references:
- JPA - multiple jars defining @Entity objects
- JPA 2.0: Adding entity classes to PersistenceUnit *from different jar* automatically
- https://www.java.net/node/665328
Good luck!
这篇关于Playframework:如何在不同项目之间共享模型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!