0
点赞
收藏
分享

微信扫一扫

使用@Component注解时 @Autowired注入为null


参考:​​Springboot @Component下@Autowired的注入为null【转】​​ 1.private static 当前component
2.PostConstruct实例化
3.调用
例:

@Component
public class GrayScaleSubscribeListener extends BasicSubscribeListener {


@Autowired
private IWebhookService webhookService;
@Autowired
private IWebhookSettingsService webhookSettingsService;

private static GrayScaleSubscribeListener grayScaleListener;

@PostConstruct
public void initGrayScale() {
grayScaleListener = this;
grayScaleListener.webhookService = this.webhookService;
grayScaleListener.webhookSettingsService = this.webhookSettingsService;
}

具体调用

grayScaleListener.webhookSettingsService.getOne(queryWrapper);


举报

相关推荐

0 条评论