dromara/Sa-Token · critical · SaTokenException
未找到 Redisson 配置文件: ${file}
Error message
未找到 Redisson 配置文件: ${file} What it means
SaTokenException thrown by SaAloneRedissonRegister.openFile when the configured sa-token.alone-redisson.file resource does not exist. The path supports classpath:, file:, and bare-path conventions (bare and classpath: resolve via ClassPathResource, file: via FileSystemResource); if resource.exists() is false the register aborts before any yaml parsing.
Source
Thrown at sa-token-plugin/sa-token-alone-redisson/src/main/java/cn/dev33/satoken/dao/alone/SaAloneRedissonRegister.java:104
} catch (SaTokenException e) {
throw e;
} catch (Exception e) {
throw new SaTokenException("解析 sa-token.alone-redisson 配置失败", e);
}
}
private static InputStream openFile(String file) throws Exception {
String path = file.trim();
Resource resource;
if (path.startsWith("classpath:")) {
resource = new ClassPathResource(path.substring("classpath:".length()));
} else if (path.startsWith("file:")) {
resource = new FileSystemResource(path.substring("file:".length()));
} else {
resource = new ClassPathResource(path);
}
if (!resource.exists()) {
throw new SaTokenException("未找到 Redisson 配置文件: " + file);
}
return resource.getInputStream();
}
}
View on GitHub (pinned to ac2c7f6e94)
Solutions
- Use an explicit prefix matching the location: classpath:alone-redisson.yaml for resources, file:/etc/app/alone-redisson.yaml for absolute filesystem paths.
- Verify the file actually ships: unzip the jar and check BOOT-INF/classes, or run resource.exists() in a test.
- Fix typos and casing in the filename to match exactly.
- If the content is small, switch to the inline sa-token.alone-redisson.config string to remove file-resolution from the equation.
Example fix
# before
sa-token:
alone-redisson:
file: redisson.yaml # not found on classpath
# after
sa-token:
alone-redisson:
file: classpath:alone-redisson.yaml # matches src/main/resources/alone-redisson.yaml Defensive patterns
Strategy: validation
Validate before calling
Resource r = path.startsWith("file:")
? new FileSystemResource(path.substring(5))
: new ClassPathResource(path.replaceFirst("^classpath:", ""));
if (!r.exists()) { fail fast with a clear message; } Type guard
boolean resourceExists(String file) { /* same resolution logic as openFile */ return resolve(file).exists(); } Try / catch
try { register(); } catch (SaTokenException e) { if (e.getMessage().startsWith("未找到 Redisson 配置文件")) { /* fix path/prefix */ } } Prevention
- Use explicit classpath:/file: prefixes instead of bare paths to avoid CWD ambiguity.
- Add a build check that the configured file is packaged (exists in the jar's classes).
When it happens
Trigger: Setting sa-token.alone-redisson.file: alone-redisson.yaml when the file sits in src/main/resources of a module not on the classpath; typos in the filename; using file: with a relative path resolved from the process CWD rather than the project root; file packed but path case-mismatched on case-sensitive filesystems.
Common situations: Multi-module builds where the yaml lives in a sibling module; running a packaged jar while pointing at a source-tree relative path; Windows-developed path casing failing on Linux.
Related errors
- 请配置 sa-token.alone-redisson.config 或 sa-token.alone-redisson
- 注解参数配置错误,格式应如:username:password
- 12002
- UsernameAndPassword 不能为空
- 未配置全局 Http Digest 认证参数
AI-assisted analysis of dromara/Sa-Token@ac2c7f6e94 (2026-08-14).
Data as JSON: /api/errors/fdcf90bee04ebc48.
Report an issue: GitHub.