美文网首页
springboot整合redis[单机版redis]

springboot整合redis[单机版redis]

作者: 番茄块块 | 来源:发表于2019-01-11 17:41 被阅读0次

PS:springboot版本用的是2.0.4.RELEASE
ps:markdown新手指南

添加redis依赖:
<!--spingboot内嵌redis-->
<dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>

ps: 简书中想插入代码有如右图效果,将代码包含在两个 ```符号之间。
ps:springboot内嵌组件依赖不需要版本号。如果依赖不是springboot内嵌的组件则需要添加版本号。

ex:
<dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.apache.commons</groupId>
                <artifactId>commons-pool2</artifactId>
                <version>2.4.3</version>
            </dependency>
        </dependencies>
</dependencyManagement>

ps:maven中<dependencyManagement>标签用于有子模块的父工程,保证子工程依赖父工程jar包版本的一致性。

redis相关配置信息:

ps:配置在application.properties文件中

################## Redis单机模式配置  ##################
## Redis数据库索引(默认为0)
spring.redis.database=0
## Redis服务器地址
spring.redis.host=112.74.56.80
## Redis服务器连接端口
spring.redis.port=6379
# springboot2.0版本配置
## 连接池最大连接数(使用负值表示没有限制)
spring.redis.jedis.pool.max-active=150
## 连接池最大阻塞等待时间(使用负值表示没有限制)
spring.redis.jedis.pool.max-wait=-1ms
## 连接池中的最大空闲连接
spring.redis.jedis.pool.max-idle=30
## 连接池中的最小空闲连接
spring.redis.jedis.pool.min-idle=10
## 连接超时时间(毫秒)
spring.redis.timeout=10000ms

相关文章

网友评论

      本文标题:springboot整合redis[单机版redis]

      本文链接:https://www.haomeiwen.com/subject/wvzxdqtx.html