Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

spring3微服务版本只能使用本机的redis #5902

Closed
cometzhao opened this issue Feb 20, 2024 · 9 comments
Closed

spring3微服务版本只能使用本机的redis #5902

cometzhao opened this issue Feb 20, 2024 · 9 comments

Comments

@cometzhao
Copy link

版本号:

spring3、微服务版本

前端版本:vue3版?还是 vue2版?

vue3

问题描述:

redis无法获取nacos中的配置,只能使用本地。以下为验证(nacos中配置的redis为:jeecg-boot-redis)

截图&代码:

image

友情提示(为了提高issue处理效率):

  • 未按格式要求发帖,会被直接删掉;
  • 描述过于简单或模糊,导致无法处理的,会被直接删掉;
  • 请自己初判问题描述是否清楚,是否方便我们调查处理;
  • 针对问题请说明是Online在线功能(需说明用的主题模板),还是生成的代码功能;
@zhangdaiscott
Copy link
Member

你启动的是那个类

@cometzhao
Copy link
Author

JeecgSystemCloudApplication

@cometzhao
Copy link
Author

启动的JeecgSystemCloudApplication,在ShiroConfig中的redisManager里打印了lettuceConnectionFactory.getHostName()。发现输出的是默认的localhost,而不是nacos中设置的jeecg-boot-redis

@cometzhao
Copy link
Author

我把本地redis停掉,启动system显示连接不上redis。nacos中已将redis改到远程
image

@zhangdaiscott
Copy link
Member

nacos启动了吗,是没连上吧还是你本地host配置的不对

@cometzhao
Copy link
Author

nacos确认已经连接上,把本地redis启动后所有服务都可以正常启动。把本地redis停用后,system启动报错。本地host文件中jeecg-boot-redis已映射到其他IP。nacos中设置的redis host: jeecg-boot-redis。
(因为改主数据库名称了,所以确认连接NACOS是正常的。把本地redis启动后,所有服务启动正常,但redis是往本地写的,通过redis客户端工具已验证)
image

@cometzhao
Copy link
Author

getHostName输出localhost就不对吧,正确的应该输出:jeecg-boot-redis

@EightMonth
Copy link
Contributor

spring boot 3的redis版本为spring.data.redis,而非spring.redis,请检查配置是否正确

@cometzhao
Copy link
Author

厉害啊大神。感谢感谢。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants