技术选型
| 技术栈 | Classify | Github | Wiki | Tutorial | Version |
|---|---|---|---|---|---|
| Spring Boot | #Framework | Spring initializr | |||
| Redis | #Cache | ||||
| MySQL | #Database | Wiki | MySQL 系列教程学习笔记 | ||
| Junit | #Test | ||||
| Lombok | #Logger | ||||
| Grpc | #Communication | EN/ZH | |||
| grpc-spring | #Grpc#Middleware | GitHub | |||
| Nginx | #Communication | Wiki | |||
| Protobuf | #Protocol | GitHub | ZH | ||
| spring-cloud-consul | #Consul #Middleware | GitHub | Wiki | Docker: 采用 hashicorp/consul | |
| Casbin | #Authorization | ZH | |||
| Jcasbin | #Casbin #Middleware | GitHub | |||
| casbin-Spring-boot-starter | #Casbin #Middleware | GitHub | |||
| Sentinel | #DashBoard #Middleware | GitHub | Wiki | Github : Grpc Github : sentinel-datasource-consul Docker: sentinel-dashboard | |
| Mybatis | #ORM | GitHub | Wiki | GitHub: spring-boot-starter |
项目计划
- 创建 Spring Boot 框架,选择 RESTful 实现接口;
- 选择 gRPC,重构 grpc-spring 框架,添加子模块 grpc-lib;
- 从 gomall 项目复制 Protobuf 文件,参考 gomall;
- 创建数据库和表,参考 schema.sql;
- 添加 Consul 依赖,参考 cloud-grpc-server 和 Docker 部署 Consul 单节点或者集群教程;
- 添加 JCasbin 依赖,参考 jcasbin;
- 添加 Sentinel 依赖,参考 sentinel;
- 添加 Sentinel-gRPC 依赖,参考 sentinel-grpc;
- 使用 Consul 设置 Sentinel 数据源,参考 sentinel-datasource-nacos;
- 添加 Casbin 拦截器,参考 casbin-spring-boot-example 和 local-grpc-server;
- 添加 MyBatis 依赖,参考 spring-boot-starter;
- 添加 MyBatis 测试用例,参考 mybatis-test;
- 添加 grpc-spring 测试用例,参考 grpc-spring;
- 实现服务,参考 gomall
- 添加服务测试用例,参考 grpc-spring;
- 修复 Consul 内部错误,参考 Consul 集群灾难恢复;
- 其他:本地 Consul 已启动,与 Docker Consul 冲突;
解决问题流程
- 查看官方文档(有官方翻译最好,或者找到对应的中文文档);
- GitHub 查找官方仓库;
- 查看问题日志,使用合适的 prompt 问 LLM;
- StackOverflow 搜索;
- 浏览器搜索;
打包
spring-boot-maven-plugin
xml
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<mainClass>com.example.demo.DemoApplication</mainClass>
</configuration>
</plugin>
</plugins>
</build>会在target目录下的demo-0.0.1-SNAPSHOT.jar文件和demo-0.0.1-SNAPSHOT.jar.original文件,可能会引起ClassNotFoundException
参考
版本号
批量修改版本号
bash
# 批量修改版本号
mvn versions:set -DnewVersion=1.0.0-SNAPSHOT
# 回退修改
mvn versions:revert
# 提交修改
mvn versions:commit参考
Git 提交规范
规范
plaintext
<type>(<scope>): <subject>
<body> (可选,补充说明)
<footer> (可选,关联任务或问题)<type>: 描述提交的类型(详见下文)。<scope>: 涉及的模块或功能范围,例如auth,api,frontend。<subject>: 简要描述本次更改,建议限制在 50 个字符以内。<body>: 补充说明(如原因、背景、实现细节等),每行不超过 72 个字符。<footer>: 关联任务(如Fixes #123)或破坏性变更说明。
类型
| 类型 | 说明 |
|---|---|
feat | 新功能,例如 feat(auth): add JWT token support |
fix | 修复 bug,例如 fix(ui): correct button alignment |
docs | 文档修改,例如 docs(readme): add setup instructions |
style | 代码格式调整(无逻辑变动),例如 style(css): format styles |
refactor | 代码重构,例如 refactor(api): simplify query parameters |
test | 添加或修改测试,例如 test(cart): add unit test for checkout |
chore | 杂项(构建、工具等),例如 chore(deps): update dependencies |
perf | 性能优化,例如 perf(image): reduce loading time |
ci | CI 配置更改,例如 ci(workflow): add deploy step |
build | 构建相关更改,例如 build(gradle): update plugin version |
revert | 回滚提交,例如 revert: remove buggy feature |