nacos运行报错Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'memoryMonitor' defined in URL [jar:file:/D:/bangong/nacos-server-2.1.0/nacos/target/nacos-server.jar!/BOOT-INF/lib/nacos-config-2.1.0.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
时间: 2024-02-26 21:56:28 浏览: 732
spring-cloud-starter-alibaba-nacos-discovery-2021.1-文档-中文版.zip
5星 · 资源好评率100%
这个错误的原因是 nacos-server 配置中使用了异步通知服务 asyncNotifyService,但是 asyncNotifyService 的构造函数中需要注入 dumpService,但是 dumpService 的初始化失败,原因是没有设置 DataSource。你可以检查一下你的配置文件中是否正确配置了 DataSource,在配置文件中添加如下配置:
```
spring.datasource.platform=mysql
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
spring.datasource.url=jdbc:mysql://localhost:3306/nacos_devtest?characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true
spring.datasource.username=root
spring.datasource.password=root
```
并将 `spring.datasource.platform` 的值设置为你使用的数据库类型,`spring.datasource.driver-class-name` 设置为你使用的数据库驱动类,`spring.datasource.url` 设置为你的数据库连接地址,`spring.datasource.username` 和 `spring.datasource.password` 分别设置为你的数据库用户名和密码。
阅读全文