diff --git a/pom.xml b/pom.xml index d545cc00c459e2e302c74a07b7f53ea22551e512..2499345a524bad270c53978fc0817f79977b425b 100644 --- a/pom.xml +++ b/pom.xml @@ -48,10 +48,14 @@ - - - - + + org.springframework.boot + spring-boot-starter-data-redis + + + org.apache.commons + commons-pool2 + org.springframework.boot spring-boot-starter-web diff --git a/sql/swpu_basic_information_sql.sql b/sql/swpu_basic_information_sql.sql index 80b14effae5894a6d0080ef638243eeae0462ca1..ec0787cb79aa5faaf3ba4c72856ef53c4aa378dc 100644 --- a/sql/swpu_basic_information_sql.sql +++ b/sql/swpu_basic_information_sql.sql @@ -1,12 +1,15 @@ create table swpu_basic_information ( - id varchar(50) not null comment '主键ID' + id varchar(50) not null comment '主键ID' primary key, - parent_id varchar(50) not null comment '父ID', - gender varchar(2) null comment '班级', - education varchar(20) null comment '教育学历', - class_grade varchar(50) null comment '班级', - contact varchar(20) null comment '联系方式', - student_number varchar(100) null comment '学生学号' -) comment '用户基本信息表'; + parent_id varchar(50) not null comment '父ID', + gender varchar(2) null comment '班级', + education varchar(20) null comment '教育学历', + class_grade varchar(50) null comment '班级', + contact varchar(20) null comment '联系方式', + student_number varchar(100) null comment '学生学号', + username varchar(20) null comment '学生姓名', + school varchar(50) null comment '学校名称' +) + comment '用户基本信息表'; diff --git a/swpu-spring-projects-boot/src/main/java/com/swpu/util/RedisConfig.java b/swpu-spring-projects-boot/src/main/java/com/swpu/util/RedisConfig.java new file mode 100644 index 0000000000000000000000000000000000000000..051e1fff19954de149fc8c54801aa51b29da0642 --- /dev/null +++ b/swpu-spring-projects-boot/src/main/java/com/swpu/util/RedisConfig.java @@ -0,0 +1,23 @@ +package com.swpu.util; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory; +import org.springframework.data.redis.core.RedisTemplate; +import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer; +import org.springframework.data.redis.serializer.StringRedisSerializer; + +@Configuration +public class RedisConfig { + + @Bean + public RedisTemplate redisTemplate(LettuceConnectionFactory lettuceConnectionFactory) { + RedisTemplate redisTemplate = new RedisTemplate<>(); + redisTemplate.setKeySerializer(new StringRedisSerializer()); + redisTemplate.setValueSerializer(new Jackson2JsonRedisSerializer<>(Object.class)); + redisTemplate.setHashKeySerializer(new StringRedisSerializer()); + redisTemplate.setHashValueSerializer(new Jackson2JsonRedisSerializer<>(Object.class)); + redisTemplate.setConnectionFactory(lettuceConnectionFactory); + return redisTemplate; + } +} diff --git a/swpu-spring-projects-boot/src/main/resources/application.yml b/swpu-spring-projects-boot/src/main/resources/application.yml index 2a647f79c18ef95c646f1c31968c923c3d2ab3c2..4093c8fa732b126a91ebe2ebc9c63b7cea3f929c 100644 --- a/swpu-spring-projects-boot/src/main/resources/application.yml +++ b/swpu-spring-projects-boot/src/main/resources/application.yml @@ -23,6 +23,23 @@ spring: max-lifetime: 1800000 # 数据库连接超时时间,默认30秒,即30000 connection-timeout: 30000 + # Redis 配置 基于 Spring Boot + redis: + # 1. IP + host: localhost + # 2. Port + port: 6379 + # 3. 密码 + password: '' + # 4. 你要用哪个 Redis 数据库 + database: 1 + # 5. 配置连接池 + lettuce: + pool: + max-active: 1000 + max-idle: 10 + min-idle: 3 + max-wait: -1 # 项目端口 server: port: 20000