springboot 集成redis (单点)

最近做一些关于springboot方面的东西,刚好抽空准备集成一下关于redis的部分,但是看 了网上的很多教程,不过都不是很对。现在完整的教程下一下,以备以后查阅使用。
springboot是属于开箱即用的那种,对于redis的使用也是一样。下面开始讲怎么使用springboot集成redis。
项目是采用maven构建,以下是需要的jar包。

<dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-cache</artifactId>
</dependency>
<dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-redis</artifactId>
        <version>1.5.6.RELEASE</version>
</dependency>

然后在application.properties 中配置关于redis的项。

spring.redis.database=0
spring.redis.host=192.168.29.128
spring.redis.password=
spring.redis.port=6379
spring.redis.pool.max-idle=8
spring.redis.pool.min-idle=0  
spring.redis.pool.max-active=8  
spring.redis.pool.max-wait=-1

只需要这样就可以完成springboot+redis的基本配置,在项目中可以通过注解的方式,将redisTemplate和stringRedisTemplate注入到MVC层中。通过提供的方法来完成对redis 的一些基本操作。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值