Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MyRealm 中依赖 提前初始化造成 获取对象为非代理对象,造成事物注解失效 #77

Closed
zhang0001 opened this issue Apr 26, 2019 · 4 comments

Comments

@zhang0001
Copy link

zhang0001 commented Apr 26, 2019

ShiroFilterFactoryBean 现了FactoryBean接口,所以它会提前被初始化。他依赖的都会提前,造成早于AnnotationAwareAspectJAutoProxyCreator 注册到 FactoryBean中,造成之前初始化的Bean 都是不是代理类。MyRealm 中的依赖 ISysPermissionService ISysUserService StringRedisTemplate RedisUtil,而ShiroFilterFactoryBean 依赖SecurityManager ,SecurityManager 依赖 MyRealm ,MyRealm 中的依赖会提前初始化,获取的是非代理对象,无法使用 @transactional @Cacheable 等注解,可以添加@lazy 延迟初始化。

@zhangdaiscott
Copy link
Member

3Q

@zhangdaiscott
Copy link
Member

public class MyRealm extends AuthorizingRealm {

@Autowired
@Lazy
private ISysUserService sysUserService;
@Autowired
@Lazy
private RedisUtil redisUtil;

看看是否正确

@zhang0001
Copy link
Author

是的

@zhangdaiscott
Copy link
Member

ok 下个版本发布

lexmeng pushed a commit to lexmeng/jeecg-boot that referenced this issue Jun 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants