现在用springboot,将公有方法抽出写成一个静态方法,方便调用
@Component
public class GetRoleUtil {
@Autowired
private UserMapper userMapper;
@Autowired
private static UserMapper staticuserMapper;
@PostConstruct
public void init() {
staticuserMapper = userMapper;
}
public static Integer getRole(String token)throws Exception{
User user = staticuserMapper.selectByPrimaryKey(adminId);
重点是注解,没有注解就会跟我一样在公司玩了3小时。。