
3年前
实现如下
@Component // 交由spring管理
public class CommonUtil {
@Autowired // 注入
private TRUserRoleService trUserRoleService;
// 声明对象
public static CommonUtil commonUtil;
@PostConstruct // 初始化
public void init(){
commonUtil = this;
commonUtil.trUserRoleService = this.trUserRoleService;
}
public static void getUserRoleList(TRUser user) {
// 调用
List<TRUserRole> userRoleList = commonUtil.trUserRoleService.findByUser(new TRUser(user.getId()));
}
}
评论已关闭 >_<