{"record":{"id":"462436145903b488","repo":"dromara/Sa-Token","slug":"code-30301","errorCode":"CODE_30301","errorMessage":"请配置：jwtSecretKey","messagePattern":"请配置：jwtSecretKey","errorType":"exception","errorClass":"SaTokenException","httpStatus":null,"severity":"error","filePath":"sa-token-plugin/sa-token-temp-jwt/src/main/java/cn/dev33/satoken/temp/jwt/SaTempTemplateForJwt.java","lineNumber":84,"sourceCode":"\n\t/**\n\t * 获取指定 value 的 temp-token 列表记录\n\t * @param value /\n\t * @return /\n\t */\n\tpublic List<String> getTempTokenList(Object value) {\n\t\tthrow new ApiDisabledException(\"jwt cannot get token list\").setCode(SaTempJwtErrorCode.CODE_30304);\n\t}\n\n\t/**\n\t * 获取jwt秘钥 \n\t * @return jwt秘钥 \n\t */\n\t@Override\n\tpublic String getJwtSecretKey() {\n\t\tString jwtSecretKey = SaManager.getConfig().getJwtSecretKey();\n\t\tif(SaFoxUtil.isEmpty(jwtSecretKey)) {\n\t\t\tthrow new SaTokenException(\"请配置：jwtSecretKey\").setCode(SaTempJwtErrorCode.CODE_30301);\n\t\t}\n\t\treturn jwtSecretKey;\n\t}\n\t\n}\n","sourceCodeStart":66,"sourceCodeEnd":90,"githubUrl":"https://github.com/dromara/Sa-Token/blob/ac2c7f6e94a78573cf0bcb932dd8b04e68fad189/sa-token-plugin/sa-token-temp-jwt/src/main/java/cn/dev33/satoken/temp/jwt/SaTempTemplateForJwt.java#L66-L90","documentation":"Thrown by SaTempTemplateForJwt.getJwtSecretKey when the global config has no jwt-secret-key value. Every JWT operation (create/parse) needs the secret for signing and verification, so the plugin fails fast rather than defaulting to an insecure key.","triggerScenarios":"Using SaTempUtil/any JWT temp-token API with sa-token.jwt-secret-key absent in application.yml; the config key is misspelled or the yml profile that defines it is not active.","commonSituations":"Adding the sa-token-temp-jwt (or sa-token-jwt) dependency without adding the config; config living in a different Spring profile; whitespace/indentation errors in yml under sa-token.","solutions":["Set the secret in configuration: sa-token.jwt-secret-key: your-strong-secret (min length per jjwt, typically >= 32 chars for HS256)","Verify the property is actually loaded (actuator /env or a breakpoint on SaManager.getConfig().getJwtSecretKey())","In multi-module projects, ensure the yml defining the key is on the active module's classpath"],"exampleFix":"# before\nsa-token:\n  token-name: satoken\n\n# after\nsa-token:\n  token-name: satoken\n  jwt-secret-key: \"PleaseChangeMe_0123456789ABCDEF\"","handlingStrategy":"validation","validationCode":"if(SaFoxUtil.isEmpty(SaManager.getConfig().getJwtSecretKey())) {\n    // fail startup with a clear message before any JWT call\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Add a startup assertion for jwt-secret-key when the jwt plugin is on the classpath","Load secrets from env/vault, not committed yml"],"tags":["sa-token","jwt","config","secret-key"],"backgroundTag":null,"analyzedSha":"ac2c7f6e94a78573cf0bcb932dd8b04e68fad189","analyzedAt":"2026-08-14T14:36:10.271Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}