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


当前回答

到目前为止,我用过的最好的逆向工程工具和往返java -> UML是Borland's Together。它是基于Eclipse的(不仅仅是一个插件),而且工作得非常好。

其他回答

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

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

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

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

另一个Java建模工具是我的网站GitUML。 从存储在GitHub存储库中的Java或Python代码生成UML图。

GitUML的一个关键思想是解决“文档化”的一个问题:图总是过时的。使用GitUML,当您使用git推送代码时,图表会自动更新。

浏览社区UML图,有一些Java设计模式。浏览流行的GitHub存储库,并可视化其中的架构和模式。

使用指向和单击创建图表。没有拖放编辑器,只需点击你想要可视化的存储库树中的类:

底层技术是基于PlantUML的,这意味着您可以使用额外的PlantUML标记来改进您的图表。

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

你的代码库是什么?Java还是c++ ?

eUML2 for Java is a powerful UML modeler designed for Java developper in Eclipse. The free edition can be used for commercial use. It supports the following features: CVS and Team Support Designed for large project with multiple and customizable model views Helios Compliant Real-time code/model synchronization UML2.1 compliant and support of OMG XMI JDK 1.4 and 1.5 support The commercial edition provides: Advanced reversed engineering Powerful true dependency analyze tools UML Profile and MDD Database tools Customizable template support

使用IntelliJ IDEA。要生成类图,选择package并按Ctrl + Alt + U:

默认情况下,它只显示类名,而不显示所有依赖项。要更改它:右键单击->显示类别…和显示依赖项:

要生成依赖关系图(UML部署图),使用maven go View -> Tool Windows -> maven Projects,并按Ctrl + Alt + U:

结果:

此外,还可以生成更多其他图表。见文档。