|
|
|
@ -27,7 +27,7 @@ import org.redisson.api.RedissonClient;
|
|
|
|
|
import org.redisson.config.Config;
|
|
|
|
|
import org.redisson.spring.data.connection.RedissonConnectionFactory;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
|
|
|
|
|
import org.springframework.boot.autoconfigure.AutoConfigureBefore;
|
|
|
|
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
|
|
|
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
|
|
|
|
import org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration;
|
|
|
|
@ -39,6 +39,9 @@ import org.springframework.context.annotation.Bean;
|
|
|
|
|
import org.springframework.context.annotation.Configuration;
|
|
|
|
|
import org.springframework.core.io.Resource;
|
|
|
|
|
import org.springframework.data.redis.connection.RedisConnectionFactory;
|
|
|
|
|
import org.springframework.data.redis.core.RedisOperations;
|
|
|
|
|
import org.springframework.data.redis.core.RedisTemplate;
|
|
|
|
|
import org.springframework.data.redis.core.StringRedisTemplate;
|
|
|
|
|
import org.springframework.util.ReflectionUtils;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -47,9 +50,9 @@ import org.springframework.util.ReflectionUtils;
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
@Configuration
|
|
|
|
|
@ConditionalOnClass(Redisson.class)
|
|
|
|
|
@AutoConfigureAfter(RedisAutoConfiguration.class)
|
|
|
|
|
@EnableConfigurationProperties(RedissonProperties.class)
|
|
|
|
|
@ConditionalOnClass({Redisson.class, RedisOperations.class})
|
|
|
|
|
@AutoConfigureBefore(RedisAutoConfiguration.class)
|
|
|
|
|
@EnableConfigurationProperties({RedissonProperties.class, RedisProperties.class})
|
|
|
|
|
public class RedissonAutoConfiguration {
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
@ -61,6 +64,22 @@ public class RedissonAutoConfiguration {
|
|
|
|
|
@Autowired
|
|
|
|
|
private ApplicationContext ctx;
|
|
|
|
|
|
|
|
|
|
@Bean
|
|
|
|
|
@ConditionalOnMissingBean(name = "redisTemplate")
|
|
|
|
|
public RedisTemplate<Object, Object> redisTemplate(RedisConnectionFactory redisConnectionFactory) {
|
|
|
|
|
RedisTemplate<Object, Object> template = new RedisTemplate<Object, Object>();
|
|
|
|
|
template.setConnectionFactory(redisConnectionFactory);
|
|
|
|
|
return template;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Bean
|
|
|
|
|
@ConditionalOnMissingBean(StringRedisTemplate.class)
|
|
|
|
|
public StringRedisTemplate stringRedisTemplate(RedisConnectionFactory redisConnectionFactory) {
|
|
|
|
|
StringRedisTemplate template = new StringRedisTemplate();
|
|
|
|
|
template.setConnectionFactory(redisConnectionFactory);
|
|
|
|
|
return template;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Bean
|
|
|
|
|
@ConditionalOnMissingBean(RedisConnectionFactory.class)
|
|
|
|
|
public RedissonConnectionFactory redissonConnectionFactory(RedissonClient redisson) {
|
|
|
|
|