Commit 3ea8a693 by tangyi

修复Redis配置失效bug

parent 29540ce8
......@@ -94,16 +94,6 @@
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
<exclusions>
<exclusion>
<groupId>redis.clients</groupId>
<artifactId>jedis</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>redis.clients</groupId>
<artifactId>jedis</artifactId>
</dependency>
<!-- 配置属性加密工具 -->
<dependency>
......
......@@ -3,7 +3,7 @@ package com.github.tangyi.common.core.config;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.core.*;
import org.springframework.data.redis.serializer.JdkSerializationRedisSerializer;
import org.springframework.data.redis.serializer.StringRedisSerializer;
......@@ -19,18 +19,16 @@ import org.springframework.data.redis.serializer.StringRedisSerializer;
public class RedisConfig {
@Bean
public JedisConnectionFactory jedisConnectionFactory() {
return new JedisConnectionFactory();
}
@Bean
public RedisTemplate<String, Object> redisTemplate() {
public RedisTemplate<String, Object> redisTemplate(RedisConnectionFactory redisConnectionFactory) {
RedisTemplate<String, Object> redisTemplate = new RedisTemplate<>();
// 存储对象需要配置序列化机制
redisTemplate.setKeySerializer(new StringRedisSerializer());
redisTemplate.setHashKeySerializer(new StringRedisSerializer());
redisTemplate.setValueSerializer(new JdkSerializationRedisSerializer());
redisTemplate.setHashValueSerializer(new JdkSerializationRedisSerializer());
redisTemplate.setConnectionFactory(jedisConnectionFactory());
// 开启事务
redisTemplate.setEnableTransactionSupport(true);
redisTemplate.setConnectionFactory(redisConnectionFactory);
return redisTemplate;
}
......
......@@ -8,7 +8,7 @@ spring:
type: com.alibaba.druid.pool.DruidDataSource
driver-class-name: com.mysql.jdbc.Driver
redis:
host: ${REDIS_HOST:localhost}
host: ${REDIS_HOST:192.168.0.213}
port: ${REDIS_PORT:6379}
rabbitmq:
host: ${RABBIT_HOST:localhost}
......
......@@ -8,7 +8,7 @@ spring:
type: com.alibaba.druid.pool.DruidDataSource
driver-class-name: com.mysql.jdbc.Driver
redis:
host: ${REDIS_HOST:localhost}
host: ${REDIS_HOST:192.168.0.213}
port: ${REDIS_PORT:6379}
rabbitmq:
host: ${RABBIT_HOST:localhost}
......
......@@ -2,7 +2,7 @@ server:
port: 8000
spring:
redis:
host: ${REDIS_HOST:localhost}
host: ${REDIS_HOST:192.168.0.213}
port: ${REDIS_PORT:6379}
boot:
admin:
......
......@@ -8,7 +8,7 @@ spring:
type: com.alibaba.druid.pool.DruidDataSource
driver-class-name: com.mysql.jdbc.Driver
redis:
host: ${REDIS_HOST:localhost}
host: ${REDIS_HOST:192.168.0.213}
port: ${REDIS_PORT:6379}
rabbitmq:
host: ${RABBIT_HOST:localhost}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment