画图之C4架构图idea和vscode环境搭建篇

本文详细介绍了如何在VS Code和IntelliJ Idea中搭建C4-PlantUML环境,包括安装相应软件、插件、代码片段和配置环境变量。还提供了解决错误的方法,以及C4-PlantUML的语法和实例,帮助读者快速上手创建架构图。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

VS Code 下C4-PlantUML安装

安装VS Code

直接官网下载安装即可,过程略去。

安装PlantUML插件

在VS Code的Extensions窗口中搜索PlantUML,安装PlantUML插件。
在这里插入图片描述

配置VS Code代码片段

安装完PlantUML之后,为了提高效率,我们最好安装PlantUML相关的代码片段。
打开VS Code菜单,层级为Code→Preferences→User Snippets,如下图:
在这里插入图片描述
或者
在这里插入图片描述

在选择Snippets File Or Create Snippets弹窗中,选择New Global Snippets file,如下图:
在这里插入图片描述
在接下来的弹窗中,输入Snippets file的文件名,如下图:
在这里插入图片描述
使用浏览器打开以下链接,并将浏览器返回的文本内容粘贴到VS Code编辑区
github链接地址
内容如下

{
	"C4_Include_Context": {
		"scope": "plantuml",
		"prefix": "Include C4 Context Diagram",
		"body": [
			"!include https://raw.githubusercontent.com/plantuml-stdlib/C4-PlantUML/master/C4_Context.puml"
		],
		"description": "Include C4 Context Diagram"
	},
	"C4_Include_Container": {
		"scope": "plantuml",
		"prefix": "Include C4 Container Diagram",
		"body": [
			"!include https://raw.githubusercontent.com/plantuml-stdlib/C4-PlantUML/master/C4_Container.puml"
		],
		"description": "Include C4 Container Diagram"
	},
	"C4_Include_Component": {
		"scope": "plantuml",
		"prefix": "Include C4 Component Diagram",
		"body": [
			"!include https://raw.githubusercontent.com/plantuml-stdlib/C4-PlantUML/master/C4_Component.puml"
		],
		"description": "Include C4 Component Diagram"
	},
	"C4_Include_Deployment": {
		"scope": "plantuml",
		"prefix": "Include C4 Deployment Diagram",
		"body": [
			"!include https://raw.githubusercontent.com/plantuml-stdlib/C4-PlantUML/master/C4_Deployment.puml"
		],
		"description": "Include C4 Deployment Diagram"
	},
	"C4_Include_Dynamic": {
		"scope": "plantuml",
		"prefix": "Include C4 Dynamic Diagram",
		"body": [
			"!include https://raw.githubusercontent.com/plantuml-stdlib/C4-PlantUML/master/C4_Dynamic.puml"
		],
		"description": "Include C4 Dynamic Diagram"
	},
	"C4_Person": {
		"scope": "plantuml",
		"prefix": "Person",
		"body": [
			"Person(${1:alias}, \"${2:label}\")"
		],
		"description": "Add Person to C4 diagram"
	},
	"C4_Person_Descr": {
		"scope": "plantuml",
		"prefix": "Person with Description",
		"body": [
			"Person(${1:alias}, \"${2:label}\", \"${3:description}\")"
		],
		"description": "Add Person with Description to C4 diagram"
	},
	"C4_Person_Ext": {
		"scope": "plantuml",
		"prefix": [
			"External Person",
			"Person (External)"
		],
		"body": [
			"Person_Ext(${1:alias}, \"${2:label}\")"
		],
		"description": "Add External Person to C4 diagram"
	},
	"C4_Person_Ext_Descr": {
		"scope": "plantuml",
		"prefix": [
			"External Person with Description",
			"Person (External) with Description"
		],
		"body": [
			"Person_Ext(${1:alias}, \"${2:label}\", \"${3:description}\")"
		],
		"description": "Add External Person with Description to C4 diagram"
	},
	"C4_Container": {
		"scope": "plantuml",
		"prefix": "Container",
		"body": [
			"Container(${1:alias}, \"${2:label}\", \"${3:technology}\")"
		],
		"description": "Add Container to C4 diagram"
	},
	"C4_Container_Descr": {
		"scope": "plantuml",
		"prefix": "Container with Description",
		"body": [
			"Container(${1:alias}, \"${2:label}\", \"${3:technology}\", \"${4:description}\")"
		],
		"description": "Add Container with Description to C4 diagram"
	},
	"C4_Container_Ext": {
		"scope": "plantuml",
		"prefix": [
			"External Container",
			"Container (External)"
		],
		"body": [
			"Container_Ext(${1:alias}, \"${2:label}\", \"${3:technology}\")"
		],
		"description": "Add External Container to C4 diagram"
	},
	"C4_Container_Ext_Descr": {
		"scope": "plantuml",
		"prefix": [
			"External Container with Description",
			"Container (External) with Description"
		],
		"body": [
			"Container_Ext(${1:alias}, \"${2:label}\", \"${3:technology}\", \"${4:description}\")"
		],
		"description": "Add External Container with Description to C4 diagram"
	},
	"C4_ContainerDb": {
		"scope": "plantuml",
		"prefix": "Database Container",
		"body": [
			"ContainerDb(${1:alias}, \"${2:label}\", \"${3:technology}\")"
		],
		"description": "Add Database Container to C4 diagram"
	},
	"C4_ContainerDb_Descr": {
		"scope": "plantuml",
		"prefix": "Database Container with Description",
		"body": [
			"ContainerDb(${1:alias}, \"${2:label}\", \"${3:technology}\", \"${4:description}\")"
		],
		"description": "Add Database Container with Description to C4 diagram"
	},
	"C4_ContainerDb_Ext": {
		"scope": "plantuml",
		"prefix": [
			"External Database Container",
			"Database Container (External)"
		],
		"body": [
			"ContainerDb_Ext(${1:alias}, \"${2:label}\", \"${3:technology}\")"
		],
		"description": "Add External Database Container to C4 diagram"
	},
	"C4_ContainerDb_Ext_D
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值