要在 GoLand 2025.2 中运行 EdgeX Foundry 的 edgex-ui-go
(基于 Go 语言的 EdgeX 管理界面),以下是详细步骤:
1. 环境准备
确保已安装以下工具:
- Go 1.18+(推荐最新稳定版)
- Node.js 14+(前端依赖)
- Docker & Docker Compose(用于启动 EdgeX 基础服务)
- Git
2. 克隆代码仓库
git clone https://github.com/edgexfoundry/edgex-ui-go.git
cd edgex-ui-go
3. 配置后端(Go)
(1) 用 GoLand 打开项目
- 通过 GoLand File → Open,选择
edgex-ui-go
目录。 - GoLand 会自动检测
go.mod
并下载依赖(或手动运行go mod tidy
)。
(2) 修改配置文件
配置文件通常为 res/configuration.toml
,检查以下关键项:
[Service]
Host = "0.0.0.0"
Port = <your-port> # e.g., 4000
[Database]
Host = "localhost"
Port = <your-db-port>
根据实际需求调整数据库、端口等参数。
(3) 运行后端
- GoLand中打开
cmd/edgex-ui-server/main.go
。 - 右键 → Run ‘main’,或使用顶部工具栏的绿色三角按钮启动。
4. 配置前端(Vue.js)
(1) 安装前端依赖
cd web/ui
npm install # 安装依赖
(2) 修改环境变量
编辑 web/ui/.env
,确保后端 API地址正确:
VUE_APP_BASE_URL=http://localhost:<backend-port> # e.g., http://localhost:4000