feat: 升级SpringBoot和SpringCloud版本
This commit is contained in:
+6
-2
@@ -1,13 +1,15 @@
|
||||
package com.central.common.redis;
|
||||
|
||||
import com.central.common.redis.properties.CacheManagerProperties;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.cache.interceptor.KeyGenerator;
|
||||
import org.springframework.boot.autoconfigure.data.redis.RedisProperties;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.cache.CacheManager;
|
||||
import org.springframework.cache.annotation.EnableCaching;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Primary;
|
||||
import org.springframework.data.redis.cache.RedisCacheConfiguration;
|
||||
import org.springframework.data.redis.cache.RedisCacheManager;
|
||||
@@ -28,10 +30,12 @@ import java.util.Map;
|
||||
* Blog: https://zlt2000.gitee.io
|
||||
* Github: https://github.com/zlt2000
|
||||
*/
|
||||
@Configuration
|
||||
@ComponentScan
|
||||
@EnableConfigurationProperties({RedisProperties.class, CacheManagerProperties.class})
|
||||
@EnableCaching
|
||||
public class RedisAutoConfigure {
|
||||
@Autowired
|
||||
@Resource
|
||||
private CacheManagerProperties cacheManagerProperties;
|
||||
|
||||
@Bean
|
||||
|
||||
+2
@@ -9,6 +9,7 @@ import org.redisson.api.RedissonClient;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@@ -25,6 +26,7 @@ import java.util.concurrent.TimeUnit;
|
||||
*/
|
||||
@ConditionalOnClass(RedissonClient.class)
|
||||
@ConditionalOnProperty(prefix = "zlt.lock", name = "lockerType", havingValue = "REDIS", matchIfMissing = true)
|
||||
@Component
|
||||
public class RedissonDistributedLock implements DistributedLock {
|
||||
@Autowired
|
||||
private RedissonClient redisson;
|
||||
|
||||
+2
@@ -3,6 +3,7 @@ package com.central.common.redis.properties;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -13,6 +14,7 @@ import java.util.List;
|
||||
@Setter
|
||||
@Getter
|
||||
@ConfigurationProperties(prefix = "zlt.cache-manager")
|
||||
@Component
|
||||
public class CacheManagerProperties {
|
||||
private List<CacheConfig> configs;
|
||||
|
||||
|
||||
+2
@@ -10,6 +10,7 @@ import org.springframework.data.redis.connection.RedisServerCommands;
|
||||
import org.springframework.data.redis.core.*;
|
||||
import org.springframework.data.redis.serializer.RedisSerializer;
|
||||
import org.springframework.data.redis.serializer.SerializationUtils;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
import java.util.*;
|
||||
@@ -25,6 +26,7 @@ import java.util.concurrent.TimeUnit;
|
||||
* Github: https://github.com/zlt2000
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class RedisRepository {
|
||||
/**
|
||||
* Spring Redis Template
|
||||
|
||||
+1
-3
@@ -1,4 +1,2 @@
|
||||
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
|
||||
com.central.common.redis.RedisAutoConfigure,\
|
||||
com.central.common.redis.lock.RedissonDistributedLock,\
|
||||
com.central.common.redis.template.RedisRepository
|
||||
com.central.common.redis.RedisAutoConfigure
|
||||
Reference in New Issue
Block a user