| | |
| | | package com.ruoyi.common.redis.configure; |
| | | |
| | | import org.redisson.Redisson; |
| | | import org.redisson.api.RedissonClient; |
| | | import org.redisson.config.Config; |
| | | import org.springframework.boot.autoconfigure.AutoConfigureBefore; |
| | | import org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration; |
| | | import org.springframework.cache.annotation.CachingConfigurerSupport; |
| | |
| | | import org.springframework.data.redis.listener.RedisMessageListenerContainer; |
| | | import org.springframework.data.redis.listener.adapter.MessageListenerAdapter; |
| | | import org.springframework.data.redis.serializer.StringRedisSerializer; |
| | | |
| | | import java.io.IOException; |
| | | |
| | | /** |
| | | * redis配置 |
| | |
| | | template.afterPropertiesSet(); |
| | | return template; |
| | | } |
| | | |
| | | @Bean(destroyMethod="shutdown") // 服务停止后调用 shutdown 方法。 |
| | | public RedissonClient redisson() throws IOException { |
| | | // 1.创建配置 |
| | | Config config = new Config(); |
| | | // 集群模式 |
| | | // config.useClusterServers().addNodeAddress("127.0.0.1:7004", "127.0.0.1:7001"); |
| | | // 2.根据 Config 创建出 RedissonClient 示例。 |
| | | config.useSingleServer().setAddress("redis://47.109.78.184:10020").setPassword("hrt123456"); |
| | | return Redisson.create(config); |
| | | } |
| | | |
| | | } |