IntelliJ 是否支持任何类型的模板来自动创建多个文件? [英] Does IntelliJ support any kind of templating to create multiple files automatically?

查看:25
本文介绍了IntelliJ 是否支持任何类型的模板来自动创建多个文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我有一个 spring mvc 应用程序,我注意到我正在做很多重复的代码(我对 java/spring 都是新手).

So I have a spring mvc application, and I am noticing there is allot of repetitive code I am doing (I'm newish to both java/spring).

每次创建新实体时,我都必须创建以下文件:

Each time I create a new entity I have to create the following files:

Entity
EntityDao
EntityDaoImpl
EntityService
EntityServiceImpl

除 Entity.java 文件(比如 User.java 或 Product.java 等)之外的所有文件几乎都是可以自动生成的.

All of the files except for the Entity.java file (say User.java or Product.java etc) are pretty much something that could be automatically generated.

有什么东西可以帮助生成这些文件(在正确的文件夹中)?

Is there anything out there that can help generate these files (in the correct folders)?

推荐答案

代码生成非常简单,最好将 IMO 排除在 IDE 等式之外.如果您看到机会,请使用 Velocity、FreeMarker 或 J. Random 模板解决方案创建一个快速工具,直到您找到更好的长期解决方案,否则就没有必要了.

Code generation is surprisingly easy, and IMO is best left out of the IDE equation. If you see an opportunity, create a quick tool using Velocity, FreeMarker, or J. Random templating solution until you figure out a better long-term solution, or it becomes unnecessary.

还要考虑简单的泛型;通常就足够了.

Also consider simple generics; it's often enough.

这篇关于IntelliJ 是否支持任何类型的模板来自动创建多个文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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