防止JHipster import-jdl在更新实体时覆盖更改 [英] Preventing JHipster import-jdl from overwriting changes when updating entities

查看:295
本文介绍了防止JHipster import-jdl在更新实体时覆盖更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在当前工作流程中,我必须检入git并在每次碰到更改的实体的import-jdl后手动读取更改,例如添加的功能.

With my current workflow I have to check in git and manually read changes like added functions after every import-jdl that touches an entitiy I changed.

是否可以在不实际更改文件的情况下向JHipster创建的类添加函数?像带有注释的代码生成或扩展JHipster创建的分类?我感觉好像缺少JHipster的一些重要文档,我将为正确方向的指针而感激.

Is there a way to add functions to the classes JHipster creates without actually changing the files? Like code generation with anotations or extending JHipster created clasees? I feel like I am missing some important documentation from JHipster, I would be grateful for pointers in the right direction.

谢谢!

推荐答案

我在我的一个项目中遇到了这个问题,恐怕没有简单的方法告诉JHipster不要覆盖您的更改.

I faced this problem in one of my projects and I'm afraid there is no easy way to tell JHipster not to overwrite your changes.

好消息是,您有两种缓解方法,这两种方法都会使您的生活更加轻松.

The good news is you have two ways of mitigating this and both will make your life much easier.

这个想法是在另一个分支中更新您的实体(执行import-jdl命令),然后,在整个过程完成之后,将更改合并回master.

The idea is to update your entities (execute the import-jdl command) in a different branch and then, once the whole process is finished merge the changes back to master.

这不需要对代码进行任何额外的更改.我用这种方法遇到的问题是,有时合并并不容易,而且我仍然必须经过大量代码才能确保一切都仍然存在并且可以正常工作.

This requires no extra changes to your code. The problem I had with this approach is that sometimes the merges were not trivial and I still had to go through a lot of code just to be sure that everything was still in place and working properly.

这被称为并行练习.通常的想法是,您永远不要直接更改生成的代码,而是将自定义代码放在新文件中,并尽可能扩展原始文件.

This is known as the side-by-side practice. The general idea is that you never change the generated code directly, instead you put your custom code in new files and extend the original ones whenever possible.

这样,您可以更新实体,并且JHipster将永远不会删除或修改您的自定义代码.

This way you can update your entities and JHipster will never remove or modify your custom code.

有两个视频可以(通过示例)教您如何管理此视频:

There are two videos available that will teach you (with examples) how to manage this:

  • Custom and Generated Code Side by Side by Antonio Goncalves
  • JHipster side-by-side in practice by David Steiman

我认为这是最好的方法.

In my opinion this is the best approach.

我知道这可能不是您想要的答案,但是据我所知,没有更好的方法.

I know this probably isn't the answer you were looking for, but to my knowledge there's no better way.

这篇关于防止JHipster import-jdl在更新实体时覆盖更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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