这是一个简单的spring-boot项目脚手架,点击标题
SpringBoot很方便,但不能开箱即用,现在开源的脚手架又过于复杂,于是整理了这个简单的脚手脚。
特性
- 简单
- 开箱即用
- 登录和鉴权
- 代码生成
- 接口文档
- 参数校验
使用库
- SpringBoot
- SpringSecurity
- Mybatis
- Mybatis Page Helper
- Apache common lang3
- Jwtt
如何开始
- 拷贝项目到本地,导入IDE,在 pom.xml 修改项目的 groupId、artifactIdgit clone git@github.com:crazyrunsnail/spring-boot-template.git my-project-name
- 在数据库执行 src/main/resources/db/migration/V1__init.sql 里的sql语句
- (可选)修改项目路径,在IDE中使用 rename 功能
- 开发业务
参考的工作流
- 数据库建模,生在SQL语句,使用 mybatis-generator 的 maven 插件生成 Model, Mapper接口和Mapper.xml。[list=1]
- 将Model中的getter和setter删除使用Lombok @Data
- 在Mapper接口上加上 @Mapper
- search
- getById
- create
- update
相对应的是三个入参DTO,分别是:
- ModelSearchParam
- ModelCreateParam
- ModelUpdateParam
对应一个出参DTO:
- ModelDTO