Thanks a lot, http://blog.csdn.net/sun_t89/article/details/51944252.
Spring boot Combat redis Cache login Verification Code
This chapter introduces the configuration of Redis and how to use it, the sample code of this article is modified on the basis of the preceding code, which realizes the process of using Redis to cache verification code and verifying the verification code.
1. Add dependent libraries (add Redis libraries, and third-party verification code libraries)
[HTML] view plain copy <dependency> <groupid>org.springframework.boot</group id> <artifactId>spring-boot-starter-redis</artifactId> </dependency> <dependency> <groupId>cn.apiclub.tool</groupId> <artifactId>simplecaptcha</artifactId> <versi On>1.2.2</version> </dependency>
2. Adding Redis configuration information to Application.properties
[HTML] view plain copy spring.redis.database=4 Spring.redis.host=hostname Spring.redis.password=password spring.redis.port=6379 spring.redis.timeout=2000 spring.redis.pool.max-idle=8 spring.redis.pool.min-idle=0 spring. Redis.pool.max-active=8 Spring.redis.pool.max-wait=-1
3. Add Redis Data Template
New Redisconfig.java
[Java] View plain copy package com.xiaofangtech.sun.config; import org.springframework.context.annotation.bean; import org.springframework.data.redis.connection.redisconnectionfactory; import org.springframework.data.redis.connection.jedis.jedisconnectionfactory; import org.springframework.data.redis.core.redistemplate; import org.springframework.data.redis.serializer.stringredisserializer; Public class RedisConfig { @Bean Jedisconnectionfactory jedisconnectionfactory () { return new jedisconnectionfactory (); } @Bean