Does IntelliJ support any template for creating multiple files automatically?

So, I have a spring mvc application, and I notice that there is a dedicated repetitive code multiplier (I'm new to java / spring).

Each time I create a new object, I need to create the following files:

Entity EntityDao EntityDaoImpl EntityService EntityServiceImpl 

All files except the Entity.java file (for example, User.java or Product.java, etc.) can be generated to a large extent automatically.

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

+4
java spring intellij-idea
Nov 15 '11 at 20:48
source share
2 answers

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

Also consider simple generics; it is often enough.

+2
Nov 16 2018-11-11T00: 00Z
source share

Unfortunately, I think the answer is no. It seems like features might be there ... They have custom file templates, but AFAIK templates are blocked in the create menu, which means one file at a time.

What you offer is very possible with Velocity or Freemarker (or any other template engine). You should find examples that do what you are looking for by looking for these tool names.

Finally, this is another topic, but I just suggest if you find yourself doing a lot of repetitive code. Perhaps there is another way to set up your project (annotations, dependency injections) or another structure (Hibernate w Seam or JPA + EJB), which may be easier for what you are trying to do. Worth exploring.

+1
Nov 16 2018-11-11T00:
source share



All Articles