报错问题1:redis无法连接
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'captchaController': Unsatisfied dependency expressed through field 'configService'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sysConfigServiceImpl': Invocation of init method failed; nested exception is org.springframework.data.redis.RedisConnectionFailureException: Unable to connect to Redis; nested exception is org.springframework.data.redis.connection.PoolException: Could not get a resource from the pool; nested exception is io.lettuce.core.RedisConnectionException: Unable to connect to ……
排查问题:检查了一下redis的启动,发现完全没有问题,也是正常运行在6379的默认端口
解决问题:重新启动了下redis,然后重新启动若依应用,发现可以运行。
复盘:在第一次启动redis的时候没有指定配置文件,而是直接使用redis-server 启动,后续重新启动了redis并且加上配置文件启动: redis-server /etc/redis.conf 之后,若依框架就能正常运行。
所以这里我的原因是没有正确启动redis并选择恰当的配置文件,属于redis配置问题,配置中需要添加类似 bind 0.0.0.0
从而允许所有IP访问。(但实际上我没有再深入求证根本原因是不是这个配置的问题)
报错问题2:
这个问题是发生在问题1之前的,是mysql数据库的问题导致应用启动出错。
后来发现是数据库的名字写错了,或者说没有把若依框架的默认数据库名称改成自己的数据库名称,错误非常低级,但是我不是第一次犯这种错误了,所以也记录一下。