!195 sa-token-solon-plugin:调整适配代码,允许没有sa-token配置内容。

Merge pull request !195 from 西东/dev
This commit is contained in:
孔明 2022-11-16 08:06:31 +00:00 committed by Gitee
commit bdcaecd5bc
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F

View File

@ -35,28 +35,30 @@ public class XPluginImp implements Plugin {
public void start(AopContext context) {
// Sa-Token 日志输出 Bean
context.getBeanAsync(SaLog.class, bean -> {
SaManager.setLog(bean);
SaManager.setLog(bean);
});
//注入其它 Bean
context.beanOnloaded(c->{
context.beanOnloaded(c -> {
beanInitDo(c);
});
}
private void beanInitDo(AopContext context){
private void beanInitDo(AopContext context) {
// 注入上下文Bean
SaManager.setSaTokenContext(new SaContextForSolon());
//注入配置Bean
SaTokenConfig saTokenConfig = Solon.cfg().getBean("sa-token", SaTokenConfig.class);
SaManager.setConfig(saTokenConfig);
if (saTokenConfig != null) {
SaManager.setConfig(saTokenConfig);
}
context.getBeanAsync(SaTokenConfig.class, bean -> {
SaManager.setConfig(bean);
});
// 注入上下文Bean
SaManager.setSaTokenContext(new SaContextForSolon());
// 注入Dao Bean
context.getBeanAsync(SaTokenDao.class, bean -> {
SaManager.setSaTokenDao(bean);