Spring Boot 项目架构

  前段时间自己整理了一份关于 SpringBoot 的项目文章, 文中对 SpringBoot 的常用技术整合通过代码做了一个比较具体的入门展示, 很高兴在自己学习的同时, 能够帮助到大家. 鉴于一些朋友想要源码, 于是自己将文章中的代码实现进一步优化, 提取成一个方便进行二次开发的脚手架项目, 并辅以非常详细的说明注释, 放在 gitee 上供大家直接学习使用, 然后删除了此篇文章的代码示例, 仅保留说明部分.

  Gitee 项目地址  Slavic , 大家先阅读 readme.md 说明, 可以快速了解整个项目, 也希望大家能够提出自己的意见或建议.

  本项目是一个 Spring boot 项目. 先看一下官方对 Spring Boot 的定义

Our primary goals are:

  • Provide a radically faster and widely accessible getting started experience for all Spring development.
  • Be opinionated out of the box, but get out of the way quickly as requirements start to diverge from the defaults.
  • Provide a range of non-functional features that are common to large classes of projects (e.g. embedded servers, security, metrics, health checks, externalized configuration).
  • Absolutely no code generation and no requirement for XML configuration.

开箱即用, 目标就是简化简化再简化开发, 嗯, 那我们的目标也是咯.

一、nginx/zuul 做 LB eureka 高可用做注册中心

二、前后分离通过 JSON 交互数据

三、Controller 层使用适配器

四、Service 层很常规

五、JWT 做 token 验证

六、AOP 做请求记录

七、mybatis generator 自动生成 mapper、model、xml

八、Logback 做日志记录

九、自定义 javadoc doclet 做接口描述文档

十、连接池使用 dbcp2

十一、redis 缓存

十二、WebMvcConfigurerAdapter 拦截器

十三、LineRunner 启动任务加载基础数据

十四、ApplicationListener 监听器

十五、数据库使用 mysql

十六、线程池用来执行 task 定时任务

十七、统一异常处理

看一下项目结构, 让我们有一个整体的了解: