@Component
public class JwtUtil {
/**
* 静态方法调用非静态接口层(Service层)
*/
public static JwtUtil jwtUtil; //声明对象
@PostConstruct //初始化
public void init() {
jwtUtil = this;
jwtUtil.userService = this.userService;
}
@Autowired //注入
UserService userService;
public static boolean checkSign(String token) {
...
String username= jwtUtil.userService.getUsernameById(userId);
...
}