【nacos服务连接异常】
这里写自定义目录标题
本地将nacos配置成服务了,但是每次自动连接时,都需要重新使用其他工具去连接一下数据才行,否则nacos连接就会出现异常,异常信息为:
2023-11-08 10:23:25,063 ERROR Application run failed
org.springframework.beans.factory.UnsatisfiedDependencyException:
Error creating bean with name ‘memoryMonitor’ defined in URL
[jar:file:/F:/Environment/nacos-server-2.0.3/target/nacos-server.jar!/BOOT-INF/lib/nacos-config-2.0.3.jar!/com/alibaba/nacos/config/server/monitor/MemoryMonitor.class]: Unsatisfied dependency expressed through constructor parameter 0;
nested exception is
org.springframework.beans.factory.UnsatisfiedDependencyException:
Error creating bean with name ‘asyncNotifyService’: Unsatisfied
dependency expressed through field ‘dumpService’; nested exception is
org.springframework.beans.factory.BeanCreationException: Error
creating bean with name ‘externalDumpService’: Invocation of init
method failed; nested exception is ErrCode:500, ErrMsg:Nacos Server
did not start because dumpservice bean construction failure : No
DataSource set
其中,nacos配置mysql的步骤
- 新建数据库nacos_config, 执行sql脚本生成表单
- 在application.properties下配置mysql相关属性
- 启动# 欢迎使用Markdown编辑器
一般都是在配置application.properties文件时出了问题, 如果直接照抄官方文档会报错, 因为mysql8.0之后的版本, 需要在官网文档配置mysql的基础上加上mysql时区的设置
正确的配置如下:
spring.datasource.platform=mysql
db.num=1
db.url.0=jdbc:mysql://127.0.0.1:3306/nacos?characterEncoding=utf8&serverTimezone=UTC&connectTimeout=10000&socketTimeout=30000&autoReconnect=true
db.user=我的mysql用户名
db.password=我的密码
注:尽量按照上述所配置的信息进行完善,否则会出现异常,本人之前采用下面方案1,就需要手动先连接数据,nacos才可连接成功,否则就会提示nacos连接数据库异常;但是使用方案2就可以一次性连接数据
- db.url.0=jdbc:mysql://127.0.0.1:3306/nacos?characterEncoding=utf8&connectTimeout=10000&socketTimeout=30000&autoReconnect=true&serverTimezone=UTC&useUnicode=true&useSSL=false
- db.url.0=jdbc:mysql://127.0.0.1:3306/nacos?characterEncoding=utf8&connectTimeout=10000&socketTimeout=30000&autoReconnect=true&serverTimezone=UTC
更多推荐



所有评论(0)