Spring Boot Combat Redis cache Login Verification Code

Source: Internet
Author: User
Tags redis

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.