慕神8447489
12345678910111213<!-- spring data redis --> <dependency> <groupId>org.springframework.data</groupId> <artifactId>spring-data-redis</artifactId> <version>1.5.1.RELEASE</version> </dependency> <!-- Jedis --> <dependency> <groupId>redis.clients</groupId> <artifactId>jedis</artifactId> <version>2.6.3</version> </dependency>你要用maven的话需要以上两个包(spring-data-redis、jedis),不用maven的话可以去网上找一下,在ioc容器中需要配置如下的bean:1234567891011121314151617<bean id="jedisPoolConfig" class="redis.clients.jedis.JedisPoolConfig"> <property name="maxIdle" value="${redis.maxIdle}"></property> <property name="maxTotal" value="${redis.maxTotal}"></property> <property name="minIdle" value="${redis.minIdle}"></property> <property name="maxWaitMillis" value="${redis.maxWaitMills}"></property> </bean> <bean id="jedisConnFactory" class="org.springframework.data.redis.connection.jedis.JedisConnectionFactory"> <property name="hostName" value="${redis.host2}"></property> <property name="port" value="${redis.port2}"></property> <property name="password" value="${redis.password}"></property> <property name="poolConfig" ref="jedisPoolConfig"></property> </bean> <bean id="stringRedisTemplate" class="org.springframework.data.redis.core.StringRedisTemplate"> <property name="connectionFactory" ref="jedisConnFactory"></property> </bean>具体以上的配置你可以去查一下