使用 Docker 安装

  1. 拉取 PlantUML 的 Docker 镜像
1
docker pull plantuml/plantuml-server:jetty
  1. 运行 PlantUML 服务器容器
1
docker run -d -p 8080:8080 plantuml/plantuml-server:jetty
  1. 访问 PlantUML 服务器

时序图

注释信息

note left

1
2
3
4
5
6
@startuml

Alice->Bob : hello
note left: this is a first note

@enduml

note right

1
2
3
4
5
6
@startuml

Bob->Alice : ok
note right: this is another note

@enduml

end note (多行注释)

1
2
3
4
5
6
7
8
9
10
@startuml

Bob->Bob : I am thinking
note left
a note
can also be defined
on several lines
end note

@enduml

对消息序列编号

autonumber

1
2
3
4
5
6
7
@startuml

autonumber
Bob -> Alice : Authentication Request
Bob <- Alice : Authentication Response

@enduml

autonumber inc

  • 要增加第一个数字,请使用:autonumber inc A 。
  • 要增加第二位数字,请使用:autonumber inc B 。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
@startuml

autonumber 1.1.1
Alice -> Bob: Authentication request
Bob --> Alice: Response

autonumber inc A
'Now we have 2.1.1
Alice -> Bob: Another authentication request
Bob --> Alice: Response

autonumber inc B
'Now we have 2.2.1
Alice -> Bob: Another authentication request
Bob --> Alice: Response

autonumber inc A
'Now we have 3.1.1
Alice -> Bob: Another authentication request
autonumber inc B
'Now we have 3.2.1
Bob --> Alice: Response

@enduml

autonumber stop

  • 停止自动编号