idea使用platuml画时序图&类图
频繁的写代码,也需要偶尔驻足消停。
今天给大家带来的不是什么java代码示例,而是带来增加软实力的画图技能(platuml代码示例)。纵观所有画uml图的软件,既不收费也对Java开发友好的软件,目前认知范围内非platuml莫属。
官网地址:https://plantuml.com/zh/ github地址:https://github.com/plantuml/plantuml
直接上图了,如果大家和我一样认为好用,咱们就继续探索。
时序图:
代码示例:
@startuml title 数据查询时序图 '隐藏脚注 hide footbox '设置别名和颜色 actor User as user #FFBBBB participant "XxxController" as controller #FEFECF participant "XxxServiceFactory" as serviceFactory #FEFECF participant "XxxService" as service #FEFECF participant "XxxDao" as dao #FEFECF '自动编号 autonumber '文本居中对齐center/left/right skinparam sequenceMessageAlign center user->controller:请求a() 'controller生命线开始 activate controller #FFBBBB controller->serviceFactory:调用b()获取具体实现的service activate serviceFactory #F9A005 serviceFactory-->controller:返回具体实现的service类 deactivate serviceFactory controller->service:调用findData()查询数据 activate service #E3F9BC service->dao:调用findList()查询数据 activate dao #C8EEF9 dao-->service:返回满足条件的数据 deactivate dao service-->controller:返回满足条件且封装后的数据 controller-->user:响应 deactivate service 'controller生命线结束 deactivate controller @enduml
java类图:
类图代码示例:
@startuml title 数据查询类图 class XxxController class XxxServiceImpl class YyyServiceImpl class ZzzServiceImpl class XxxServiceFactory interface XxxService interface BaseMapper interface XxxDao interface YyyDao interface ZzzDao '虚线箭头代表接口实现,实现箭头代表类继承,无箭头虚线代表存在关联关系 XxxController .. XxxService XxxServiceFactory .. XxxService XxxServiceImpl .. XxxDao YyyServiceImpl .. YyyDao ZzzServiceImpl .. ZzzDao '定义类属性、方法、颜色 class XxxController #FEFFCF { - XxxService xxxService + List findData(...) } class XxxServiceFactory #FEFFCF { + XxxService getService(...) } interface XxxService #FEFFCF { + List findData(...) } class XxxServiceImpl<Xxx> #FEFFCF implements XxxService { - XxxDao xxxDao + List<Xxx> findData(...) } class YyyServiceImpl<Yyy> #FEFFCF implements XxxService { - YyyDao yyyDao + List<Yyy> findData(...) } class ZzzServiceImpl<Yyy> #FEFFCF extends YyyServiceImpl { - ZzzDao xzzDao + List<Zzz> findData(...) } interface BaseMapper #FEFFCF {} interface XxxDao<Xxx> #FEFFCF extends BaseMapper { + List<Xxx> findData() } interface YyyDao<Yyy> #FEFFCF extends BaseMapper { + List<Yyy> findData() } interface ZzzDao<Yyy> #FEFFCF extends BaseMapper { + List<Zzz> findData() } @enduml
探索不以困难而止,学习不以艰苦而终