使用了@Component和@Autowired注入后还是null

首先这个方法是在你检查了所有原因后才解决不了的。

我的注入不了的代码是:

什么原因导致无法注入我也不太清楚。不过有个奇怪的显现就是,他可以在其他类里面注入成功。如果有大佬知道原因欢迎评论。我看了好多资料都没找到原因。这个类文件注入不进去对象一定不是因为Application位置的问题。

直接上方法。

第一种方法是:这种方法我没成功

不过大家可以试试。

private static ParsingData2 parsingData2;
    @PostConstruct
    public void init(){
        parsingData2=this;
        parsingData2.equipmentInfoMapper=this.equipmentInfoMapper;
    }

第二种方法根据set方法注入:

看这次就有东西了,不为空了。

private static TotalEquipmentMapper totalEquipmentMapper;
    @Autowired
    public void setTotalEquipmentMapper (TotalEquipmentMapper totalEquipmentMapper){
        ParsingData2.totalEquipmentMapper=totalEquipmentMapper;
    }
    private static GlMapper glMapper;
    @Autowired
    public void setGlMapper(GlMapper glMapper){
        ParsingData2.glMapper=glMapper;
    }

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值