在 Eclipse 中使用的最佳 Java 代码生成工具或插件是什么?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/360282/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What are the best Java code generation tools or plugins to use in Eclipse?
提问by Chinnery
I'm aware of the built in code generation and refactoring one can do with the "Source" and "Refactor" menu items in Eclipse.
我知道可以使用 Eclipse 中的“源”和“重构”菜单项进行内置代码生成和重构。
I also use the Commonclipse plugin to easily make use of the Apache Commons classes that build hashCode, toString, equals methods.
我还使用 Commonclipse 插件来轻松利用构建 hashCode、toString、equals 方法的 Apache Commons 类。
What other plugins or tools should I be aware of for generating Java source easily under the Eclipse IDE?
为了在 Eclipse IDE 下轻松生成 Java 源代码,我应该注意哪些其他插件或工具?
回答by nzpcmad
It really depends on what you want to do? J2EE, web services, Swing ...
这真的取决于你想做什么?J2EE、Web 服务、Swing ...
I do a lot of web service development and rely heavily on:
我进行了大量的 Web 服务开发并严重依赖:
For Axis2 development:
对于 Axis2 开发:
- 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
有一个关于 Axis2 插件的很好的教程,称为使用 Apache Axis2 Eclipse 插件开发 Web 服务 - 第 1 部分
回答by Brian Matthews
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.
如果您有兴趣进一步了解代码生成并进入模型驱动软件开发,您应该查看openArchitectureWare。
If you work through the Getting Startedtutorial you should get up to speed pretty quickly.
如果您完成了入门教程,您应该可以很快上手。
回答by Eric
I don't know if you're a big UML fan but IBM Rational suiteis extremly powerful.
我不知道您是否是 UML 的忠实粉丝,但IBM Rational 套件非常强大。
I used it to move from UML to generated mock objects but that's only a slight part of what it can do
我用它从 UML 移动到生成的模拟对象,但这只是它可以做的一小部分
回答by serg10
I don't think that this is really what you're asking about, but for model driven development, I think Borland's Togetheris still the best eclipse based tool out there.
我不认为这真的是你要问的,但对于模型驱动的开发,我认为Borland's Together仍然是最好的基于 eclipse 的工具。
回答by fastcodejava
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
您可以查看http://fast-code.sourceforge.net/以了解基于 Spring 的应用程序。您可以通过键入 foo 来创建 FooService 和 FooServiceImpl 以及配置。它也有很好的方式来创建单元测试。可以在这里看到所有模板:http: //fast-code.sourceforge.net/templates-config.xml
回答by AWhitford
Project Lombokenables 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.
Project Lombok使您能够有效地进行速记编码。比如你可以声明一个类,添加一个lombok注解,它会自动生成getter、setter、equals、hashCode、toString、构造函数。
回答by Andrejs
Eclipse Xtendis a very powerful code generator that, among other things, supports closures and data classes - automatic getters/setters/hashCode/equals.
Eclipse Xtend是一个非常强大的代码生成器,除其他外,它支持闭包和数据类 - 自动 getter/setter/hashCode/equals。
回答by rlopez
Telosys( http://www.telosys.org/) is a simple and efficient tool for Java code generation.
Telosys( http://www.telosys.org/) 是一个简单而高效的 Java 代码生成工具。
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).
此代码生成器可用作Eclipse 插件( http://marketplace.eclipse.org/content/telosys-tools) 和命令行界面( 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).
定义所有实体的模型可以从头开始(DSL 文本模型)或从现有数据库(DB 模型)创建。
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.
这些模板基于Velocity( http://velocity.apache.org),可以从 GitHub 下载。所有模板都是可定制的,如有必要,可以从头开始创建新模板。现有模板可以为JPA、Spring MVC、数据库文档、REST API等生成代码。
回答by Fastcoder
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.
如果你想生成独立于技术的代码,Zontroy 是一个不错的选择。所以你不需要考虑你的项目是不是JavaEE项目。您可以从数据库中以任何技术生成任何文件。
回答by Meghs Dhameliya
jsoncafe.comonline code generator for the model class for JAVA, Android Gson, Swift Class, Swift Codable, c# etc.
jsoncafe.com在线代码生成器,用于 JAVA、Android Gson、Swift 类、Swift Codable、c# 等模型类。