本帖最后由 VioletKiss 于 2021-6-7 11:31 编辑
ShiroConfig.java 下修改
[Java] 纯文本查看 复制代码
@Autowired
RoleService roleService;
@Autowired
PowerService powerService;
//自定义realm
@Bean
public Realm myrealm() {
MyRealm myRealm = new MyRealm(roleService,powerService);
myRealm.setCredentialsMatcher(hashedCredentialsMatcher());
myRealm.setAuthenticationCachingEnabled(true);//认证缓存
myRealm.setAuthorizationCachingEnabled(true);//授权缓存
return myRealm;
}
@Bean
public Realm myadminrealm() {
myAdminRealm myRealm = new myAdminRealm(roleService,powerService);
myRealm.setCredentialsMatcher(hashedCredentialsMatcher());
myRealm.setAuthenticationCachingEnabled(true);
myRealm.setAuthorizationCachingEnabled(false);
return myRealm;
}
然后Realm这样改
[Java] 纯文本查看 复制代码 RoleService roleService;
PowerService powerService;
MyRealm(RoleService roleService, PowerService powerService) {
this.roleService = roleService;
this.powerService = powerService;
}
能解决报listener的问题,但是出现了另一个问题,我也不知道为啥,还有ArticleServiceImpl.java没加注解,类名首字母大写,规范要注意呀
Error creating bean with name 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' 主要是要解决这个问题 |