对于springboot无法连接redis解决方案
一、测试是否能在本地应用上访问到你的redis(如果是部署在linux上的话)
1. 开启telnet功能
2. 开始测试端口是否能访问到(适用于所有,包括MQ)
telnet 192.168.**.***(换成自己的)
如果访问不到,就看3开放端口,能访问到直接看4
3. 开放6379端口
firewall-cmd --zone=public --add-port=6379/tcp --permanent
4. 看spring的配置文件 注意redis的缩进位置
server:
port: 8082
spring:
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
username: root
password: 123456
url: jdbc:mysql://localhost:3306/seckill?serverTimezone=GMT%2B8&useSSL=false
redis:
host: 192.168.**.***
port: 6379
password: 123456
database: 0
rocketmq:
name-server: 192.168.**.***:9876
# consumer:
# access-key: ??????????????
# secret-key:
mybatis:
mapper-locations: classpath:mapper/*.xml
configuration:
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl #?????????????
千万别写成:
spring:
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
username: root
password: 123456
url: jdbc:mysql://localhost:3306/seckill?serverTimezone=GMT%2B8&useSSL=false
data
redis:
host: 192.168.**.***
port: 6379
password: 123456
database: 0
5. pom依赖
也有可能是pom依赖没加的问题
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
标签:springboot,解决方案,mysql,redis,192.168,6379,端口,spring
From: https://blog.csdn.net/f552126506/article/details/140963440