# springboot-mybatis-transaction **Repository Path**: luo-shizhong/springboot-mybatis-transaction ## Basic Information - **Project Name**: springboot-mybatis-transaction - **Description**: 利用springboot+mybatis验证事务 - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2021-10-21 - **Last Updated**: 2022-06-16 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README 1.在springboot项目中自定义的Realm中(继承实现AuthorizingRealm)的doGetAuthorizationInfo方法中授权方法中给用户添加角色。 修改的方法:参考代码 @Override protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principalCollection) { String username = (String) SecurityUtils.getSubject().getPrincipal(); SimpleAuthorizationInfo info = new SimpleAuthorizationInfo(); Set stringSet = new HashSet<>(); Set rolesSet = new HashSet<>();//新建角色set数组 stringSet.add("user:show"); stringSet.add("user:admin"); info.setStringPermissions(stringSet); rolesSet.add(userMapper.getUserByName(username).getRole()); info.setRoles(rolesSet);//放到数组注入SimpleAuthorizationInfo return info; } 2.controller层方法上加上注解 参考注解: @RequiresRoles("root")