简体   繁体   English

如何使用JHipster重用.java实体?

[英]How to reuse .java entities with JHipster?

I have a quantity of (commented) JPA entities as .java files that I want to reuse with a brand new JHipster generated project. 我有一些(注释的)JPA实体作为.java文件,我想用一个全新的JHipster生成的项目重用。 They are documented so I dont want to regenerate them. 它们都有记录,所以我不想再生它们。

So far, from exchanging on the chat, an option would be to use JHipster-UML. 到目前为止,通过交换聊天,一个选项是使用JHipster-UML。 Meaning I must use my javas to produce a valid XMI file then used by JHipster-UML to produce JSON describing the entities. 意思是我必须使用我的javas生成一个有效的XMI文件,然后由JHipster-UML用来生成描述实体的JSON。 Then the JSON is to be used by JHipster. 然后JSON将由JHipster使用。

The first option I thought of was to generate text to be fed to JHipster (with << on unices) 我想到的第一个选项是生成要传递给JHipster的文本(使用<< on unices)

Is there something cooking for that usage (say ".java import") ? 有没有为这种用法做饭(比如“.java import”)?

What is advised as of today ? 今天的建议是什么?

Thank you 谢谢

The problem with converting java entity files to json, is that only certain entity options are supported by jhipster. 将java实体文件转换为json的问题是jhipster只支持某些实体选项。 So, it's not the conversion that's difficult, it's adding the support for the options to the generators. 因此,转换并不困难,它正在为发电机添加对选项的支持。

I use JDL , which isn't automatic but is still fairly simple to create existing entities and relationships. 我使用的是JDL ,它不是自动的,但创建现有的实体和关系仍然相当简单。

I did a similar approach in a recent project. 我在最近的一个项目中做了类似的方法。 I used an UML tool and imported my classes and used JHipster-UML afterwards to create the json-files. 我使用了一个UML工具并导入了我的类,然后使用JHipster-UML创建了json文件。 Then, I copied the java files into the package domain (where JHipster will generate your entity classes). 然后,我将java文件复制到包domain (JHipster将生成您的实体类)。 Then, I run Jhipster to generate the entities. 然后,我运行Jhipster来生成实体。 Since JHipster checks, if the file is already present (and/or identical), I just use "do not overwrite". 由于JHipster检查,如果文件已经存在(和/或相同),我只使用“不要覆盖”。

Obviously, this means, that your entity-classes must follow the conventions of Jhipster, so that the rest resources and services are working. 显然,这意味着您的实体类必须遵循Jhipster的约定,以便其他资源和服务正常工作。

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

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