10 changed files with 210 additions and 140 deletions
@ -1,35 +1,26 @@ |
|||||||
package com.logpm.warehouse.config; |
package com.logpm.warehouse.config; |
||||||
|
|
||||||
import org.redisson.Redisson; |
//@Configuration
|
||||||
import org.redisson.config.Config; |
|
||||||
import org.springblade.core.redis.cache.BladeRedis; |
|
||||||
import org.springblade.core.tool.utils.SpringUtil; |
|
||||||
import org.springframework.context.annotation.Bean; |
|
||||||
import org.springframework.context.annotation.Configuration; |
|
||||||
import org.springframework.data.redis.connection.RedisConnectionFactory; |
|
||||||
import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory; |
|
||||||
|
|
||||||
@Configuration |
|
||||||
public class RedissonConfig { |
public class RedissonConfig { |
||||||
|
|
||||||
@Bean |
// @Bean
|
||||||
public Redisson redisson() { |
// public Redisson redisson() {
|
||||||
// 单机模式
|
// // 单机模式
|
||||||
Config config = new Config(); |
// Config config = new Config();
|
||||||
|
//
|
||||||
BladeRedis bean = SpringUtil.getBean(BladeRedis.class); |
// BladeRedis bean = SpringUtil.getBean(BladeRedis.class);
|
||||||
|
//
|
||||||
RedisConnectionFactory connectionFactory = bean.getRedisTemplate().getConnectionFactory(); |
// RedisConnectionFactory connectionFactory = bean.getRedisTemplate().getConnectionFactory();
|
||||||
|
//
|
||||||
LettuceConnectionFactory factory = (LettuceConnectionFactory) connectionFactory; |
// LettuceConnectionFactory factory = (LettuceConnectionFactory) connectionFactory;
|
||||||
|
//
|
||||||
String hostName = factory.getHostName(); |
// String hostName = factory.getHostName();
|
||||||
int port = factory.getPort(); |
// int port = factory.getPort();
|
||||||
String password = factory.getPassword(); |
// String password = factory.getPassword();
|
||||||
|
//
|
||||||
config.useSingleServer().setAddress("redis://"+hostName+":"+port).setDatabase(2); |
// config.useSingleServer().setAddress("redis://"+hostName+":"+port).setDatabase(2);
|
||||||
config.useSingleServer().setPassword(password); |
// config.useSingleServer().setPassword(password);
|
||||||
return (Redisson) Redisson.create(config); |
// return (Redisson) Redisson.create(config);
|
||||||
} |
// }
|
||||||
|
|
||||||
} |
} |
||||||
|
Loading…
Reference in new issue