快速创建 Nebula 框架项目的命令行工具。
git clone https://github.com/gOODiDEA2002/nebula-cli.git
cd nebula-cli
go build -o nebula .# 交互式创建
nebula init
# 快速创建
nebula init my-service --type=service
# 创建完整微服务项目(包含多个服务)
nebula init my-project --type=multi-service --services=user,order| 模板 | 命令 | 说明 |
|---|---|---|
| multi-service | --type=multi-service |
完整微服务项目 |
| service | --type=service |
单个微服务 |
| web | --type=web |
Web 应用 |
| gateway | --type=gateway |
API 网关 |
| lib | --type=lib |
公共库模块 |
| minimal | --type=minimal |
最小化应用 |
| api | --type=api |
RPC 契约模块 |
# 列出可用模板
nebula templates
# 检查开发环境
nebula doctor
# 查看版本
nebula versionnebula init [project-name] [flags]| 参数 | 说明 | 默认值 |
|---|---|---|
-t, --type |
项目类型 | - |
-g, --group |
Maven groupId | com.example |
--version |
项目版本 | 1.0.0-SNAPSHOT |
--package |
基础包名 | 自动生成 |
--nebula-version |
Nebula 框架版本 | 2.0.1-SNAPSHOT |
--services |
服务列表 (multi-service) | user,order |
--no-gateway |
不包含网关 | false |
--no-lib |
不包含公共库 | false |
-y, --yes |
跳过确认 | false |
nebula init user-service --type=service --group=com.example --yes生成结构:
user-service/
├── pom.xml
├── README.md
└── src/main/java/com/example/userservice/
├── UserServiceApplication.java
├── controller/
└── service/
user-service-api/
├── pom.xml
└── src/main/java/com/example/userservice/api/
├── UserRpcClient.java
└── dto/
nebula init my-project --type=multi-service \
--services=user,order,payment \
--group=com.example \
--yes生成结构:
my-project/
├── pom.xml
├── my-project-lib/
├── my-project-user-api/
├── my-project-user/
├── my-project-order-api/
├── my-project-order/
├── my-project-payment-api/
├── my-project-payment/
└── my-project-gateway/
make buildmake testmake releaseMIT License