当前位置:网站首页>plantuml介绍与使用
plantuml介绍与使用
2022-07-01 21:43:00 【birdyson】
介绍
好用的免费画图插件,兼容vscode、IDEA等大牌IDE,使用编写代码的方式自动生成UML图形。官方中文文档:https://plantuml.com/zh/
安装方式
以IDEA为例,直接在Plugin
-> Marketplace
中安装即可,vscode同理。
入门
在文件目录中新建文件,可以看到PlantUML File
,新建此文件,选中你需要的UML图形。
UML绘图语法规则
全局规则
作用域
puml需要将代码写在@startuml
与@enduml
之间才能生效。
顺序图
箭头
@startuml
Client -> Server: 建立连接
' ↓这里为了可读性也可以反过来写成: <--
Server --> Client: 数据交互
Client --> Server: 数据交互
Server -> Client: 断开连接
@enduml
箭头样式:
No | 字段 | 表示 |
---|---|---|
1 | x | 丢失信息,箭头尾处为x |
2 | > | 实心箭头 |
3 | >> | 虚心箭头 |
4 | - | 实线 |
5 | – | 虚线 |
6 | <-> | 双向箭头 |
声明参与者
可以通过声明参与者的方式,为参与者更改属性、赋予别名as
(一旦赋予别名后续不可再使用原名)、设置权重order
(数量越小越靠前)。
@startuml
participant Client as c order 1
participant Server as s order 2
c -> s: 建立连接
s --> c: 数据交互
c --> s: 数据交互
s -> c: 断开连接
@enduml
可以使用的参与者属性:
No | 字段 | 表示 |
---|---|---|
1 | participant | 参与者 |
2 | actor | 角色 |
3 | control | 控制 |
4 | entity | 实体 |
5 | database | 数据库 |
6 | collections | 集合 |
7 | queue | 队列 |
8 | boundary | 边界 |
文字对齐
skinparam sequenceMessageAlign center
消息序号
autonumber 1.1
,指定自增数字,默认增加最后一个数字,可指定自增数字位。
@startuml
'https://plantuml.com/sequence-diagram
participant Client as c order 1
participant Server as s order 2
autonumber 1.1
c -[#red]> s: 建立连接
autonumber inc A
s --> c: 数据交互
c --> s: 数据交互
autonumber inc A
s -> c: 断开连接
@enduml
注释
note left:、
note right: 单行注释或者使用 note left ... endnote
多行注释。
分隔符
== 重复 ==
或... 重复 ...
间距
|||
设置间距,或指定间距||45||
生命线
activate c
初始化生命,deactivate c
结束生命线,可以嵌套使用。
返回
生命线可以返回内容,使用return
返回,同时可以配合autoactivate
实现自动生命线声明与销毁。
快捷创建、销毁、生命线/实例
@startuml
alice -> bob ++ : hello
bob -> bob ++ : self call
bob -> bib ++ #005500 : hello
bob -> george ** : create
return done
return rc
bob -> george !! : delete
return success
@enduml
也可以同时进行:
@startuml
alice -> bob ++ : hello1
bob -> charlie --++ : hello2
charlie --> alice -- : ok
@enduml
活动图
箭头
-->
代表普通箭头-[labels]->
代表带标签的箭头-left->
指定方向的箭头(down, up, left, right)
开始与结束
(*)
开始/结束start
/stop
开始/结束
边栏推荐
猜你喜欢
PMP与NPDP之间的区别是什么?
Do you want to make up for the suspended examination in the first half of the year? Including ten examinations for supervision engineers, architects, etc
Flume面试题
【MySQL】explain的基本使用以及各列的作用
Spark面试题
Introduction and download of the latest version of airserver2022
手动实现function isInstanceOf(child,Parent)
焱融看 | 混合云时代下,如何制定多云策略
Pytest collection (2) - pytest operation mode
业务可视化-让你的流程图'Run'起来
随机推荐
pytest合集(2)— pytest運行方式
Fundamentals - IO intensive computing and CPU intensive computing
I received a letter from CTO inviting me to interview machine learning engineer
Qtreeview+qabstractitemmodel custom model: the third of a series of tutorials [easy to understand]
MySQL learning notes - SQL optimization of optimization
100年仅6款产品获批,疫苗竞争背后的“佐剂”江湖
中通笔试题:翻转字符串,例如abcd打印出dcba
Unity 使用Sqlite
Medium pen test questions: flip the string, such as ABCD, print out DCBA
浏览器tab页之间的通信
【直播回顾】战码先锋首期8节直播完美落幕,下期敬请期待!
Is PMP certificate really useful?
微软、哥伦比亚大学|GODEL:目标导向对话的大规模预训练
Go - exe corresponding to related dependency
企业架构与项目管理的关联和区别
选择在同花顺上炒股开户可以吗?安全吗?
杰理之蓝牙耳机品控和生产技巧【篇】
分离字符串中的字母和数字并使得字母在前数组在后
K-means based user portrait clustering model
都能看懂的LIS(最长上升子序列)问题[通俗易懂]