如何从现有的Java代码生成UML图(特别是序列图)?


当前回答

我注意到Intellij的SequenceDiagram插件也是一个不错的选择。

其他回答

我注意到Intellij的SequenceDiagram插件也是一个不错的选择。

您也可以尝试使用netbeans UML建模器。我用它来生成我在eclipse项目中使用的javcode。您甚至可以在netbeans中导入eclipse项目,并保持eclipse设置与netbeans项目设置同步。

我尝试了几个用于eclipse的UML建模器,但都不满意。它们要么不稳定,要么复杂,要么丑陋不堪。: -)

ObjectAid UML Explorer

是我用的。它很容易从存储库安装:

Name:     ObjectAid UML Explorer
Location: http://www.objectaid.com/update/current

并生成相当不错的UML图:

网站描述:

The ObjectAid UML Explorer is different from other UML tools. It uses the UML notation to show a graphical representation of existing code that is as accurate and up-to-date as your text editor, while being very easy to use. Several unique features make this possible: Your source code and libraries are the model that is displayed, they are not reverse engineered into a different format. If you update your code in Eclipse, your diagram is updated as well; there is no need to reverse engineer source code. Refactoring updates your diagram as well as your source code. When you rename a field or move a class, your diagram simply reflects the changes without going out of sync. All diagrams in your Eclipse workspace are updated with refactoring changes as appropriate. If necessary, they are checked out of your version control system. Diagrams are fully integrated into the Eclipse IDE. You can drag Java classes from any other view onto the diagram, and diagram-related information is shown in other views wherever applicable.

我是作者之一,所以答案可能有偏见。它是开源的(Apache 2.0),但是插件不是免费的。如果你克隆并在本地构建它,你就不需要付费。

在Intellij IDEA上,ZenUML可以从Java代码生成序列图。

请登录https://plugins.jetbrains.com/plugin/12437-zenuml-support查看

源代码:https://github.com/ZenUml/jetbrains-zenuml

我发现绿色插件非常简单,使用和生成类图从源代码。 试一试吧。 只需将插件复制到插件目录。