mirror of
http://git.pig4cloud.com/pig/pigx.git
synced 2026-11-11 05:19:00 +08:00
♻️ Refactoring code. RedisTemplateConfig 优先于 Redisson 配置
This commit is contained in:
1 parent
3197cac20f
commit
3af30a0e9e
1 file changed
+4
-2
+4
-2
@@ -19,10 +19,10 @@ package com.pig4cloud.pigx.common.data.cache;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.boot.autoconfigure.AutoConfigureBefore;
|
||||
import org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration;
|
||||
import org.springframework.cache.annotation.EnableCaching;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Primary;
|
||||
import org.springframework.data.redis.connection.RedisConnectionFactory;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.data.redis.serializer.JdkSerializationRedisSerializer;
|
||||
@@ -36,10 +36,12 @@ import org.springframework.data.redis.serializer.StringRedisSerializer;
|
||||
@EnableCaching
|
||||
@Configuration
|
||||
@AllArgsConstructor
|
||||
@AutoConfigureBefore(RedisAutoConfiguration.class)
|
||||
@AutoConfigureBefore(name = {"org.redisson.spring.starter.RedissonAutoConfiguration"
|
||||
, "org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration"})
|
||||
public class RedisTemplateConfig {
|
||||
|
||||
@Bean
|
||||
@Primary
|
||||
public RedisTemplate<String, Object> redisTemplate(RedisConnectionFactory redisConnectionFactory) {
|
||||
RedisTemplate<String, Object> redisTemplate = new RedisTemplate<>();
|
||||
redisTemplate.setKeySerializer(new StringRedisSerializer());
|
||||
|
||||
Reference in new issue
Block a user