Nacos-2.2.1启动报错 the length of secret key must great than or equal 32 bytes;

在新的版本中,nacos增强了鉴权的功能,官方说明如下:
https://nacos.io/zh-cn/docs/v2/guide/user/auth.html

Nacos-2.2.1启动报错 the length of secret key must great than or equal 32 bytes;_第1张图片
需要自己在nacos的配置中添加自定义的密码,如下所示,生成一个base64的密钥串:

package com.xinyue.game.common;

import java.nio.charset.StandardCharsets;

import org.springframework.util.Base64Utils;
import org.testng.annotations.Test;

/**
 * @author 王广帅
 * @since 2023/6/6 21:24
 **/
public class NacosSecret {

    private String nacosSecret = "98564sfrtgdfghtyudasdfgefgdefdes";

    @Test
    public void createSecret() {
        byte[] data = nacosSecret.getBytes(StandardCharsets.UTF_8);
        System.out.println(Base64Utils.encodeToString(data));
        
    }
}

配置的nacos的的配置中,conf/application.properties中:
Nacos-2.2.1启动报错 the length of secret key must great than or equal 32 bytes;_第2张图片

你可能感兴趣的:(java,nacos)