1.安装redis 启动服务端 客户端自己操作

springboot redis配置

springboot redis配置

2.项目pom.xml直接添加依赖

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-redis</artifactId>
    </dependency>

</dependencies>

3.application.properties配置

spring.redis.host=localhost
spring.redis.port=6379
spring.redis.password=
spring.redis.database=0
spring.redis.jedis.pool.max-active=8
spring.redis.jedis.pool.max-idle=8
spring.redis.jedis.pool.min-idle=0
spring.redis.jedis.pool.max-wait=-1ms
spring.redis.timeout=10000ms

springboot redis配置

4.实例

注入依赖 

springboot redis配置

5.获取方式

6.实体注入 第一次有sql语句 接下来就是从缓存里取出来 

相关文章: