解决Nacos2.2.1启动报错

报错原因

Caused by: 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 http://xxx....
Caused by: java.lang.IllegalArgumentException: 
          The specified key byte array is x bits which is not secure enough for any JWT HMAC-SHA algorithm.  
          The JWT JWA Specification (RFC 7518, Section 3.2) states that keys used with HMAC-SHA algorithms MUST have a size >= 256 bits (the key size must be greater than or equal to the hash output size).

原因总结

很明显,报错原因是secret key参数 长度不够 打开nacos文件夹 -> conf -> application.properties 找到以下配置: nacos.core.auth.plugin.nacos.token.secret.key= 在后面添加随机参数作为nacos的加密密钥, 规则是加密密钥长度 >=256 bits 或者 >= 32 bytes

我添加了50位英文、数字成功运行

执行

startup.cmd -m standalone

最终结果

成功点亮

经验分享 程序员 微信小程序 职场和发展