diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 72db206..04f9be5 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -4,7 +4,11 @@ - - - - - file://$PROJECT_DIR$/src/main/java/cn/edu/hactcm/service/impl/OrdersServiceImpl.java - 37 - - - + + + \ No newline at end of file diff --git a/pom.xml b/pom.xml index bef2595..65d6531 100644 --- a/pom.xml +++ b/pom.xml @@ -80,6 +80,10 @@ 1.1.23 + + org.springframework.boot + spring-boot-starter-data-redis + diff --git a/src/main/java/cn/edu/hactcm/config/RedisConfig.java b/src/main/java/cn/edu/hactcm/config/RedisConfig.java new file mode 100644 index 0000000..ecfeacb --- /dev/null +++ b/src/main/java/cn/edu/hactcm/config/RedisConfig.java @@ -0,0 +1,24 @@ +package cn.edu.hactcm.config; + +import org.springframework.cache.annotation.CachingConfigurerSupport; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.data.redis.connection.RedisConnectionFactory; +import org.springframework.data.redis.core.RedisTemplate; +import org.springframework.data.redis.serializer.StringRedisSerializer; + +@Configuration +public class RedisConfig extends CachingConfigurerSupport { + + @Bean + public RedisTemplate redisTemplate(RedisConnectionFactory connectionFactory) { + RedisTemplate redisTemplate = new RedisTemplate<>(); + + //默认的Key序列化器为:JdkSerializationRedisSerializer + redisTemplate.setKeySerializer(new StringRedisSerializer()); // key序列化 + //redisTemplate.setValueSerializer(new GenericJackson2JsonRedisSerializer()); // value序列化 + + redisTemplate.setConnectionFactory(connectionFactory); + return redisTemplate; + } +} diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 69ac670..0aa8245 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -10,6 +10,10 @@ spring: url: jdbc:mysql://localhost:3306/reggie?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&useSSL=false&allowPublicKeyRetrieval=true username: root password: yjx062711. + redis: + host: localhost + port: 6379 + database: 0 mybatis-plus: configuration: #在映射实体或者属性时,将数据库中表名和字段名中的下划线去掉,按照驼峰命名法映射