# 第一种办法就是for循环,每次进行set
for (int i = 0; i < 1000000; i++) {
redisTemplate.opsForSet().add("key",i);
}
# 第二中办法就是使用HashSet批量添加数据
Set set = new HashSet<>();
for (int i = 1; i < 1000000; i++) {
set.add(i);
}
redisTemplate.opsForSet().add("key",set.toArray());
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jedisConnectionFactory' defined in class path resource [application-context.xml]: Invocation of init method failed; nested exception is java.lang.NoSuchMethodError: redis.clients.jedis.JedisShardInfo.setTimeout(I)V
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1482)at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:521) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:458) at org.springframework.beans.factory.support.AbstractBeanFactory$1