|
| 1 | +# 1. SpringBoot整合MybatisPlus |
| 2 | + |
| 3 | +## 1.1 准备数据库脚本 |
| 4 | + |
| 5 | +~~~sql |
| 6 | +DROP TABLE IF EXISTS user; |
| 7 | + |
| 8 | +CREATE TABLE user |
| 9 | +( |
| 10 | + id BIGINT(20) NOT NULL COMMENT '主键ID', |
| 11 | + name VARCHAR(30) NULL DEFAULT NULL COMMENT '姓名', |
| 12 | + age INT(11) NULL DEFAULT NULL COMMENT '年龄', |
| 13 | + email VARCHAR(50) NULL DEFAULT NULL COMMENT '邮箱', |
| 14 | + PRIMARY KEY (id) |
| 15 | +); |
| 16 | + |
| 17 | +INSERT INTO user (id, name, age, email) VALUES |
| 18 | +( 1, 'Jone', 18, '[email protected]'), |
| 19 | +( 2, 'Jack', 20, '[email protected]'), |
| 20 | +( 3, 'Tom', 28, '[email protected]'), |
| 21 | +( 4, 'Sandy', 21, '[email protected]'), |
| 22 | +( 5, 'Billie', 24, '[email protected]'); |
| 23 | + |
| 24 | + |
| 25 | + |
| 26 | +~~~ |
| 27 | + |
| 28 | +```properties |
| 29 | +spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver |
| 30 | +spring.datasource.username=root |
| 31 | +spring.datasource.password=root |
| 32 | +spring.datasource.url=jdbc:mysql://localhost:8889/springboot04?useUnicode=true&characterEncoding=UTF-8&serverTimeZone=UTC |
| 33 | + |
| 34 | +## sql init 2.5.0 change into this file |
| 35 | +spring.sql.init.schema-locations=classpath*:sql/*.sql |
| 36 | +spring.sql.init.data-locations=classpath*:sql/data/*.sql |
| 37 | + |
| 38 | +``` |
| 39 | + |
| 40 | +## 1.2 新建SpringBoot工程 |
| 41 | + |
| 42 | +~~~xml |
| 43 | + <dependencies> |
| 44 | + <dependency> |
| 45 | + <groupId>org.springframework.boot</groupId> |
| 46 | + <artifactId>spring-boot-starter-web</artifactId> |
| 47 | + </dependency> |
| 48 | + <dependency> |
| 49 | + <groupId>org.springframework.boot</groupId> |
| 50 | + <artifactId>spring-boot-starter-test</artifactId> |
| 51 | + <scope>test</scope> |
| 52 | + </dependency> |
| 53 | + |
| 54 | + |
| 55 | + <dependency> |
| 56 | + <groupId>mysql</groupId> |
| 57 | + <artifactId>mysql-connector-java</artifactId> |
| 58 | + </dependency> |
| 59 | + |
| 60 | + |
| 61 | + <dependency> |
| 62 | + <groupId>com.baomidou</groupId> |
| 63 | + <artifactId>mybatis-plus-boot-starter</artifactId> |
| 64 | + <version>3.4.3</version> |
| 65 | + </dependency> |
| 66 | + |
| 67 | + <dependency> |
| 68 | + <groupId>org.projectlombok</groupId> |
| 69 | + <artifactId>lombok</artifactId> |
| 70 | + </dependency> |
| 71 | + </dependencies> |
| 72 | +~~~ |
| 73 | + |
| 74 | + |
| 75 | + |
| 76 | +## 1.3是 |
| 77 | + |
| 78 | +# 2. SpringBoot整合Redis |
| 79 | + |
| 80 | + |
| 81 | + |
| 82 | +# 3. SpringBoot整合RocketMQ |
| 83 | + |
| 84 | + |
| 85 | + |
| 86 | +# 4. SpringBoot整合ES |
| 87 | + |
| 88 | + |
| 89 | + |
| 90 | +# 5. SpringBoot整合SpringSecurity |
| 91 | + |
| 92 | +## 5.1 导入依赖 |
| 93 | + |
| 94 | +~~~xml |
| 95 | + <dependency> |
| 96 | + <groupId>org.springframework.boot</groupId> |
| 97 | + <artifactId>spring-boot-starter-security</artifactId> |
| 98 | + </dependency> |
| 99 | +~~~ |
| 100 | + |
| 101 | +## 5.2 数据库准备 |
| 102 | + |
| 103 | + |
| 104 | + |
| 105 | +## 5.3 代码 |
| 106 | + |
| 107 | +整合有两种方式 |
| 108 | + |
| 109 | +### 5.3.1 UserDetailService |
| 110 | + |
0 commit comments