{"record":{"id":"f87bb7cfc47a699e","repo":"dromara/Sa-Token","slug":"sa-token-alone-redisson","errorCode":null,"errorMessage":"解析 sa-token.alone-redisson 配置失败","messagePattern":"解析 sa-token\\.alone-redisson 配置失败","errorType":"exception","errorClass":"SaTokenException","httpStatus":null,"severity":"critical","filePath":"sa-token-plugin/sa-token-alone-redisson/src/main/java/cn/dev33/satoken/dao/alone/SaAloneRedissonRegister.java","lineNumber":89,"sourceCode":"\t * 解析 Redisson 原生 yaml：优先 config，其次 file\n\t */\n\tpublic static Config buildConfig(SaAloneRedissonProperties properties) {\n\t\ttry {\n\t\t\tConfig config;\n\t\t\tif (StringUtils.hasText(properties.getConfig())) {\n\t\t\t\tconfig = Config.fromYAML(properties.getConfig());\n\t\t\t} else if (StringUtils.hasText(properties.getFile())) {\n\t\t\t\ttry (InputStream in = openFile(properties.getFile())) {\n\t\t\t\t\tconfig = Config.fromYAML(in);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tthrow new SaTokenException(\"请配置 sa-token.alone-redisson.config 或 sa-token.alone-redisson.file\");\n\t\t\t}\n\t\t\treturn config;\n\t\t} catch (SaTokenException e) {\n\t\t\tthrow e;\n\t\t} catch (Exception e) {\n\t\t\tthrow new SaTokenException(\"解析 sa-token.alone-redisson 配置失败\", e);\n\t\t}\n\t}\n\n\tprivate static InputStream openFile(String file) throws Exception {\n\t\tString path = file.trim();\n\t\tResource resource;\n\t\tif (path.startsWith(\"classpath:\")) {\n\t\t\tresource = new ClassPathResource(path.substring(\"classpath:\".length()));\n\t\t} else if (path.startsWith(\"file:\")) {\n\t\t\tresource = new FileSystemResource(path.substring(\"file:\".length()));\n\t\t} else {\n\t\t\tresource = new ClassPathResource(path);\n\t\t}\n\t\tif (!resource.exists()) {\n\t\t\tthrow new SaTokenException(\"未找到 Redisson 配置文件: \" + file);\n\t\t}\n\t\treturn resource.getInputStream();\n\t}","sourceCodeStart":71,"sourceCodeEnd":107,"githubUrl":"https://github.com/dromara/Sa-Token/blob/ac2c7f6e94a78573cf0bcb932dd8b04e68fad189/sa-token-plugin/sa-token-alone-redisson/src/main/java/cn/dev33/satoken/dao/alone/SaAloneRedissonRegister.java#L71-L107","documentation":"SaTokenException (wrapping the original as cause) thrown by SaAloneRedissonRegister.buildConfig when Config.fromYAML fails for either the inline config string or the file — i.e. malformed yaml, invalid Redisson option names/values, or IO errors while reading the file. It is the generic catch-all after the specific 'not configured' (116) and 'file not found' (118) cases have been separated out.","triggerScenarios":"sa-token.alone-redisson.config containing invalid yaml (tabs, bad indentation, unterminated quotes) or Redisson options that don't exist for the bundled Redisson version; file: pointing to a yaml with e.g. clusterConfig missing required fields; encoding issues in the file.","commonSituations":"Copying a Redisson yaml from a different Redisson major version (options renamed between 2.x/3.x); using tabs instead of spaces; a file whose content is actually JSON.","solutions":["Inspect e.getCause() — it carries the underlying Redisson/IO exception with the exact yaml line.","Validate the yaml separately (e.g. redisson's Config.fromYAML in a scratch test) against the exact Redisson version the plugin ships.","Replace tabs with spaces and fix indentation; ensure option names match Redisson's schema (singleServerConfig, clusterServersConfig, ...).","If reading from file:, confirm the file parses as yaml, not JSON (Redisson supports json via fromJSON instead)."],"exampleFix":"# before (invalid: tab indentation)\nsa-token:\n  alone-redisson:\n    config: |\n      singleServerConfig:\n      \\taddress: redis://127.0.0.1:6381\n\n# after\nsa-token:\n  alone-redisson:\n    config: |\n      singleServerConfig:\n        address: \"redis://127.0.0.1:6381\"\n        database: 1","handlingStrategy":"try-catch","validationCode":"// in a unit test, parse the same yaml the app will use\nConfig.fromYAML(new ClassPathResource(\"alone-redisson.yaml\").getInputStream()); // fails here, not at boot","typeGuard":null,"tryCatchPattern":"try { SaAloneRedissonRegister.buildConfig(props); } catch (SaTokenException e) { Throwable c = e.getCause(); // c holds the yaml/Redisson parse error with line info; fix config accordingly }","preventionTips":["Keep the Redisson yaml version-locked to the Redisson version the plugin ships; re-validate after dependency upgrades.","Use spaces-only indentation and validate the file in CI with a parse test."],"tags":["alone-redisson","yaml","redisson","config-parse"],"backgroundTag":null,"analyzedSha":"ac2c7f6e94a78573cf0bcb932dd8b04e68fad189","analyzedAt":"2026-08-14T14:36:10.271Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}