本文主要是介绍spring xml 集成Redission集群,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
1、引入redission
<jackson-databind.version>2.8.2</jackson-databind.version><jackson-core.version>2.8.2</jackson-core.version><dependency><groupId>org.redisson</groupId><artifactId>redisson</artifactId><version>2.10.4</version></dependency><dependency><groupId>org.codehaus.jackson</groupId><artifactId>jackson-mapper-asl</artifactId><version>1.9.13</version></dependency><dependency><groupId>com.fasterxml.jackson.core</groupId><artifactId>jackson-databind</artifactId><version>${jackson-databind.version}</version></dependency><dependency><groupId>com.fasterxml.jackson.core</groupId><artifactId>jackson-core</artifactId><version>${jackson-core.version}</version></dependency>
2、如果有jackson版本冲突 排除jira包冲突 一般高版本兼容低版本
3、集成redission集群nodes 172.0.0:8080,172.0.0:8080
@Configuration
public class RedissionConfig {private static Logger log = LoggerFactory.getLogger(RedissionConfig.class);@Value("${ucs.redis.nodes}")private String nodes;@Bean(name="redissonClient")public RedissonClient init(){Set<String> set = Arrays.stream(nodes.split(",")).collect(Collectors.toSet());String[] strings = set.stream().map(uri -> "redis://" + uri).toArray(String[]::new);System.out.println("结果:"+strings);Config config = new Config();config.useClusterServers().addNodeAddress(strings).setTimeout(500).setConnectTimeout(1000).setMasterConnectionPoolSize(100);RedissonClient redissonClient = Redisson.create(config);log.info("初始化RedissonClient");return redissonClient;}
4 xml引入
<!-- 相当于基于注解的启动类 AnnotationConfigApplicationContext--><context:annotation-config /><bean class="com.weihui.enterprise.domainservice.main.service.redisson.RedissionConfig"/>
这篇关于spring xml 集成Redission集群的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!