简体   繁体   中英

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

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?

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.

Eclipse Xtend是一个非常强大的代码生成器,除其他外,它支持闭包和数据类 - 自动 getter/setter/hashCode/equals。

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

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.

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.

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

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:

For Axis2 development:

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

我不认为这真的是你要问的,但对于模型驱动的开发,我认为Borland's Together仍然是最好的基于 eclipse 的工具。

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.

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

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.

jsoncafe.com在线代码生成器,用于 JAVA、Android Gson、Swift 类、Swift Codable、c# 等模型类。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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