Spring Boot Redis添加密码

两种方式

第一种

1.直接在config文件中找到 requirepass foobared 去掉注释 默认密码为foobared 

2.直接在命令行启动redis即可  redis-server redis.config

第二种

1.先启动Redis服务

2.在命令行输入 redis-cli  进入redis 命令

3. 

设置密码命令

config set requirepass 密码

查询密码

config get requirepass

 

 auth 密码

红色箭头方向的内容为设置的密码

 

项目配置

application.yml 配置

spring:       
    redis:
      host: 127.0.0.1
      #redis密码,没有密码的可以用~表示
      password: 密码
      port: 6379
      database: 0
      timeout: 60s
      lettuce:
        pool:
          # 最大空闲连接数
          max-idle: 500
          # 最小空闲连接数
          min-idle: 50
          # 等待可用连接的最大时间,负数为不限制
          max-wait:  -1s
          # 最大活跃连接数,负数为不限制
          max-active: -1

Pom 配置

		<!-- redis -->
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-data-redis</artifactId>
		</dependency>
		<dependency>
			<groupId>org.apache.commons</groupId>
			<artifactId>commons-lang3</artifactId>
		</dependency>
		<dependency>
			<groupId>org.apache.commons</groupId>
			<artifactId>commons-pool2</artifactId>
		</dependency>

 

 

 

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值