本文最后更新于 2 分钟前,文中所描述的信息可能已发生改变。
技术选型
项目计划
- create spring-boot framework, choose restful
- choose grpc, recreate grpc-spring framework, add submodule interface-grpc
- copy protobuf files from gomall project, reference gomall
- create database and tables, reference schema.sql
- add consul dependency, reference cloud-grpc-server and Docker 部署 Consul 单节点或者集群教程
- add jcasbin dependency, reference jcasbin
- add sentinel dependency, reference sentinel
- add sentinel-grpc dependency, reference sentinel-grpc
- use consul set sentinel datasource, reference sentinel-datasource-nacos
- add casbin interceptor, reference casbin-spring-boot-example and local-grpc-server
- add mybatis dependency, reference spring-boot-starter
- add mybatis test example, reference mybatis-test
- add grpc-spring test example, reference grpc-spring
- implement services, reference gomall
- add service test cases, reference grpc-spring
- fix consul internal error, reference Disaster recovery for Consul clusters
- other: local consul already started, conflict with docker consul
问题查找流程
- 查看官方文档(有官方翻译最好,或者找到对应的中文文档)
- GitHub 查找官方仓库
- 查看问题日志,问 GPT
- 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 |