mirror of
https://gitee.com/dromara/sa-token.git
synced 2024-11-30 10:58:05 +08:00
commit
78238641a3
@ -438,6 +438,25 @@ spring.mvc.throw-exception-if-no-handler-found=true
|
||||
|
||||
|
||||
|
||||
### Q:开启了懒加载后,启动报“未能获取有效的上下文处理器”
|
||||
开启了`lazy-initialization=true`后,启动报异常 `InvalidContextException`: 未能获取有效的上下文处理器, 配置如下:
|
||||
``` yaml
|
||||
spring:
|
||||
main:
|
||||
lazy-initialization: true
|
||||
```
|
||||
原因是sa-token自动配置入口类SaTokenContextRegister被延迟加载了,只需要手动指定懒加载排除掉SaTokenContextRegister就可以了,实现代码如下:
|
||||
```java
|
||||
@Configuration
|
||||
class MyConfiguration {
|
||||
@Bean
|
||||
LazyInitializationExcludeFilter integrationLazyInitExcludeFilter() {
|
||||
return LazyInitializationExcludeFilter.forBeanTypes(SaTokenContextRegister.class);
|
||||
}
|
||||
}
|
||||
```
|
||||
[经验来源](https://gitee.com/dromara/sa-token/issues/I7EXIU)
|
||||
|
||||
|
||||
<!-- ---------------------------- 常见疑问 ----------------------------- -->
|
||||
|
||||
|
@ -74,10 +74,6 @@ public class SaAloneRedisInject implements EnvironmentAware{
|
||||
if(saTokenDao == null || saTokenDao instanceof SaTokenDaoDefaultImpl) {
|
||||
return;
|
||||
}
|
||||
// 如果配置文件不包含相关配置,则不进行任何操作
|
||||
if(environment.getProperty(ALONE_PREFIX + ".host") == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
// ------------------- 开始注入
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user