Nacos2.2.1启动报错

1.问题描述

第一次使用nacos,使用的是当前最新版2.2.1,按照官网的启动指令,结果启动失败:
指令:

startup.cmd -m standalone

报错有很多,其中一段是:

Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘basicAuthenticationFilter’ defined in class path resource [com/alibaba/nacos/prometheus/filter/PrometheusAuthFilter.class]: Unsatisfied dependency expressed through method ‘basicAuthenticationFilter’ parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘nacosAuthConfig’ defined in URL [jar:file:/E:/env/nacos/target/nacos-server.jar!/BOOT-INF/lib/nacos-plugin-default-impl-2.2.1.jar!/com/alibaba/nacos/plugin/auth/impl/NacosAuthConfig.class]: Unsatisfied dependency expressed through constructor parameter 1; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘tokenManagerDelegate’: Unsatisfied dependency expressed through field ‘jwtTokenManager’; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘jwtTokenManager’ defined in URL [jar:file:/E:/env/nacos/target/nacos-server.jar!/BOOT-INF/lib/nacos-plugin-default-impl-2.2.1.jar!/com/alibaba/nacos/plugin/auth/impl/token/impl/JwtTokenManager.class]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.alibaba.nacos.plugin.auth.impl.token.impl.JwtTokenManager]: Constructor threw exception; nested exception is java.lang.IllegalArgumentException: the length of secret key must great than or equal 32 bytes; And the secret key must be encoded by base64.Please see https://nacos.io/zh-cn/docs/v2/guide/user/auth.html

2.查找原因

可以看到上述报错红色部分说:必须有一个长度大于等于32bytes的secret key,根据给出的网址https://nacos.io/zh-cn/docs/v2/guide/user/auth.html可以看到,nacos没有给出secret.key的默认值了,所以需要自己配置一下。
在这里插入图片描述

3.解决方式

3.1 进入nacos的conf文件夹,找到application.properties配置文件,在配置文件中找到secret.key;

在这里插入图片描述

3.2 使用随机字符串生成工具(我用的是这个),生成一段大于等于32位的随机字符作为key写在配置文件,保存后重启nacos即可。

在这里插入图片描述

在这里插入图片描述

3.3 重启成功

在这里插入图片描述

参考

  • 5
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值