问题描述
我想用PlantUML中的成员写一个注释。具体来说,我想在PlantUML中描述这段Java代码:
public @interface Foo {
String bar();
String baz();
}
我尝试用 PlantUML 编写它,但它导致语法错误:
@startuml
annotation Foo {
String bar()
String baz()
}
@enduml
但是,当我省略成员时它可以工作:
@startuml
annotation Foo
@enduml
我该怎么办?谢谢。
解决方法
在 PlantUML 中,注解不能有成员(因此会出现语法错误)。
要为您的代码显示 UML 图,您需要使用另一种解决方案,例如将注释添加为单独的实体:
@startuml
annotation interface
class Foo {
String bar();
String baz();
}
interface -- Foo
@enduml
或者在类名定义中包含注解:
@startuml
class "@interface Foo" as Foo {
String bar();
String baz();
}
@enduml
,
现在可以使用成员编写注释:http://www.plantuml.com/plantuml/uml/SoWkIImgAStDuKhCoyilIIp9pCzJSClFLwZcKW22u9AYpBnqXQJ48WrDL84ge40jbqDgNWfGCm00
根据comment,它从版本 V1.2020.2 开始可用。