3

一个简单springboot起步模板脚手架

 7 months ago
source link: https://www.jdon.com/72395.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

一个简单springboot起步模板脚手架 - 极道

这是一个简单的spring-boot项目脚手架,点击标题
SpringBoot很方便,但不能开箱即用,现在开源的脚手架又过于复杂,于是整理了这个简单的脚手脚。

  • 登录和鉴权
  • SpringBoot
  • SpringSecurity
  • Mybatis
  • Mybatis Page Helper
  • Apache common lang3
  1. 拷贝项目到本地,导入IDE,在 pom.xml 修改项目的 groupId、artifactIdgit clone [email protected]:crazyrunsnail/spring-boot-template.git my-project-name
  2. 数据库执行 src/main/resources/db/migration/V1__init.sql 里的sql语句
  3. (可选)修改项目路径,在IDE中使用 rename 功能

参考的工作流

  1. 数据库建模,生在SQL语句,使用 mybatis-generator 的 maven 插件生成 Model, Mapper接口和Mapper.xml。[list=1]
  2. 将Model中的getter和setter删除使用Lombok @Data
  3. 在Mapper接口上加上 @Mapper
新增对应 Service 的接口实现,常规会有四个方法和实现,分别是:
  • search
  • getById
  • create
  • update
相对应的是三个入参DTO,分别是:
  • ModelSearchParam
  • ModelCreateParam
  • ModelUpdateParam
对应一个出参DTO:
  • ModelDTO
新增对应的 Controller 调用对应 Service 并对结果进行包装和文档化

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK