⭐⭐⭐ Spring Boot 项目实战 ⭐⭐⭐ Spring Cloud 项目实战
《Dubbo 实现原理与源码解析 —— 精品合集》 《Netty 实现原理与源码解析 —— 精品合集》
《Spring 实现原理与源码解析 —— 精品合集》 《MyBatis 实现原理与源码解析 —— 精品合集》
《Spring MVC 实现原理与源码解析 —— 精品合集》 《数据库实体设计合集》
《Spring Boot 实现原理与源码解析 —— 精品合集》 《Java 面试题 + Java 学习指南》

摘要: 原创出处 开源技术专栏 「骑猪看星星」欢迎转载,保留摘要,谢谢!


🙂🙂🙂关注**微信公众号:【芋道源码】**有福利:

  1. RocketMQ / MyCAT / Sharding-JDBC 所有源码分析文章列表
  2. RocketMQ / MyCAT / Sharding-JDBC 中文注释源码 GitHub 地址
  3. 您对于源码的疑问每条留言将得到认真回复。甚至不知道如何读源码也可以请教噢
  4. 新的源码解析文章实时收到通知。每周更新一篇左右
  5. 认真的源码交流微信群。

diboot 的设计理念

  • Web 开发需要一个普适的基础框架,把复杂的问题简单化,最好还能做到更佳性能,规避常见的坑
  • 程序员很难被替代,但程序员应该聚焦于数据结构设计、业务实现、难点解决,重复 CRUD 没啥长进
  • 低代码是未来的趋势,CRUD 类重复有规律的工作是可以被自动化甚至被省掉的

diboot 主要技术栈

  • 后端 Java + 关系数据库,跟紧 Spring 体系 (Spring Boot、Spring Cloud)
  • ORM 站队 Mybatis,通用 Mappe r框架选用 Mybatis-plus
  • 权限: spring boo 版本使用 Shiro+JWT;spring cloud 版本使用 spring security + oauth2
  • 前后分离,前端选型 Vue,支持 ElementUI 和 Antd vue pro

diboot 基础组件

  • diboot-core: 精简优化内核:写得更少,性能更好
  • IAM 身份认证基础组件 及 配套 VUE 前端框架(diboot-antd-admin、diboot-element-admin)
  • diboot-file 文件相关处理组件
  • diboot-scheduler 定时任务组件
  • diboot-message 消息通知组件
  • diboot-mobile 移动端组件

diboot-core (diboot-core-starter) 使用步骤

1.引入依赖

<dependency>
<groupId>com.diboot</groupId>
<artifactId>diboot-core-spring-boot-starter</artifactId>
<version>{latestVersion}</version>
</dependency>

或 Gradle:

compile("com.diboot:diboot-core-spring-boot-starter:{latestVersion}")

2.配置参数(数据源)

#datasource config
spring.datasource.url=jdbc:mysql://localhost:3306/diboot_example?characterEncoding=utf8&serverTimezone=GMT%2B8
spring.datasource.username=diboot
spring.datasource.password=123456
spring.datasource.hikari.maximum-pool-size=5
spring.datasource.hikari.driver-class-name=com.mysql.cj.jdbc.Driver
-------------------------------------------------------------------------
#diboot-core-spring-boot-starter的可选参数配置:
# 是否初始化sql,默认true,初始化之后(或非开发环境)可以改为false关闭检测
diboot.core.init-sql=false

3.配置config类

diboot-core-starter 默认预置了 mybatis-plus 的分页配置(使用 mybatis-plus 3.4.x的 MybatisPlusInterceptor 最新配置方式)。如果您依赖的是core-starter,则无需再次配置 mybatis-plus 的分页。如果需要添加其他Interceptor,则需要重新定义 MybatisPlusInterceptor。示例如下:

@Bean
public MybatisPlusInterceptor mybatisPlusInterceptor() {
MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
interceptor.addInnerInterceptor(new PaginationInnerInterceptor());
return interceptor;
}
#同时core-starter中也默认配置了HttpMessageConverters,如果需要更改默认配置, 则需要在配置类中重新定义HttpMessageConverters。
@Bean
public HttpMessageConverters jacksonHttpMessageConverters() {
...
}

注意:diboot-core-starter 预置了默认的配置以及字典表相关的接口实现,如果是老项目中仅依赖 diboot-core(非diboot-core-starter),则还需要将 diboot 的包路径加入 ComponentScan 中

diboot 新手体验

在 IDE 中克隆 playground 项目

"File -> New -> Project from version control..."菜单打开克隆项目对话框:

URL 中输入如下 playground 项目路径,指定项目本地路径(避免中文路径),点击 Clone 按钮 :https://gitee.com/dibo_software/playground.git

待克隆完成后,在右侧 Maven 视图中,添加 demo 项目下的 pom.xml

准备数据库后使用 devtools 初始化代码

  • 点击控制台中打印出的 URL,进入devtools操作页面。(个人用户初次使用需要扫码)
  • 初次启动 devtools 会提示初始化组件的基础代码(为了方便自定义修改,devtools 将controller 等代码生成到本地项目中)。依次点击各组件的"生成代码"按钮。
  • 打开 demo 目录下的 java 目录,将会看到相关组件的初始化代码已生成。

注意:如果启动前端发现验证码无法显示,则需要检查是否执行了这个步骤并重启了项目。登录验证相关的 controller 需要此步骤中生成

开源地址:

  • https://gitee.com/dibo_software/diboot
文章目录
  1. 1. diboot 的设计理念
  2. 2. diboot 主要技术栈
  3. 3. diboot 基础组件
  4. 4. diboot-core (diboot-core-starter) 使用步骤
    1. 4.1. 1.引入依赖
      1. 4.1.1. 或 Gradle:
    2. 4.2. 2.配置参数(数据源)
    3. 4.3. 3.配置config类
  5. 5. diboot 新手体验
    1. 5.1. 在 IDE 中克隆 playground 项目