What are the best Java code generation tools or plugins to use in Eclipse?

走远了吗. 提交于 2020-08-20 18:47:30

问题


I'm aware of the built in code generation and refactoring one can do with the "Source" and "Refactor" menu items in Eclipse.

I also use the Commonclipse plugin to easily make use of the Apache Commons classes that build hashCode, toString, equals methods.

What other plugins or tools should I be aware of for generating Java source easily under the Eclipse IDE?


回答1:


Telosys ( http://www.telosys.org/ ) is a simple and efficient tool for Java code generation.

This code generator is available as an Eclipse Plugin (http://marketplace.eclipse.org/content/telosys-tools) and also as a Command Line Interface (https://github.com/telosys-tools-bricks/telosys-cli/wiki).

The model defining all the entities can be created from scratch (DSL text model) or from an existing database (DB model).

The templates are based on Velocity (http://velocity.apache.org) and can be downloaded from GitHub. All the templates are customizable and new templates can be created from scratch if necessary. Existing templates can generate code forJPA, Spring MVC, Database documentation, REST API, etc.




回答2:


Project Lombok enables you to effectively code in shorthand. For example, you can declare a class, add a lombok annotation, and it will automatically generate getters, setters, equals, hashCode, toString, and constructors.




回答3:


You can look at http://fast-code.sourceforge.net/ for spring based applications. You can create FooService and FooServiceImpl and the configurations just by typing foo. It has nice way to create unit tests as well. One can see all the templates here : http://fast-code.sourceforge.net/templates-config.xml




回答4:


Eclipse Xtend is a very powerful code generator that, among other things, supports closures and data classes - automatic getters/setters/hashCode/equals.




回答5:


If your are interested in going a bit further with code generation and getting into model driven software development you should have a look at openArchitectureWare.

If you work through the Getting Started tutorial you should get up to speed pretty quickly.




回答6:


Here are three java code generators that you may find interesting :

  • picocog : A tiny code generation library (< 8 KB) written in Java, useful for any purpose, but ideal for JSR-269. There are tutorials available at dev.to and dzone.com.

  • The JmrTeam generator : Jet Model Robotization available for Eclipse (coming soon for IDEA), useful for managing and generating code in any kind of project(Maven, Gradle, Java, Python, Php etc.), any kind of framework(springboot/spring/springMVC, React/ Vue/Angular, hibernate, mybatis, struts, JPA etc.).

  • javapoet : A Java API for generating .java source files.

  • jhipster :An open Source application platform for creating Spring Boot + Angular/React/Vue projects. The generator source code is available here




回答7:


It really depends on what you want to do? J2EE, web services, Swing ...

I do a lot of web service development and rely heavily on:

  • Web Services Explorer

For Axis2 development:

  • Code Generator Wizard Guide for Eclipse Plug-in
  • Service Archive Generator Wizard Guide for Eclipse Plug-in

There's a good tutorial on Axis2 plugins called Developing Web Services Using Apache Axis2 Eclipse Plugins - Part 1




回答8:


I don't think that this is really what you're asking about, but for model driven development, I think Borland's Together is still the best eclipse based tool out there.




回答9:


I just released my personal Java code generator: JCG. You can find it at

https://github.com/makkax/JavaCodeGenerator

It's a generator written in Java where you directly code all Java types, fields, methods & annotations without the need of templates.

With JCG you can easily generate any number of Java types with complex interdependencies.




回答10:


I don't know if you're a big UML fan but IBM Rational suite is extremly powerful.

I used it to move from UML to generated mock objects but that's only a slight part of what it can do




回答11:


jsoncafe.com online code generator for the model class for JAVA, Android Gson, Swift Class, Swift Codable, c# etc.




回答12:


If you want to generate code independent of technology, Zontroy is a good choice. So you don't need to think about whether your project is a JavaEE project or not. You can generate any file in any technology from your database.



来源:https://stackoverflow.com/questions/360282/what-are-the-best-java-code-generation-tools-or-plugins-to-use-in-eclipse

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!