标签:出现 wired pre 异常 img tco mmm alt sys
@Component
public class CommMain{
@Autowired
public SysTransRecordCommonService sysTransRecordCommonService;
public void saveTrans(SysTransRecord sysTransRecord){
sysTransRecordCommonService.save(sysTransRecord);
}
}
出现无法正常注入的情况,网上找了很多方法,最终以下这种方法亲测可用!
@Component public class CommMain { @Autowired public SysTransRecordCommonService sysTransRecordCommonService; public static CommMain commMain; @PostConstruct public void init(){ commMain = this; commMain.sysTransRecordCommonService = this.sysTransRecordCommonService; }
public void saveTrans(SysTransRecord sysTransRecord){
commMain.sysTransRecordCommonService.save(sysTransRecord);
} }
好了,亲测可以正常存表!
使用@Autowired注解无法注入(使用service报空指针异常)的问题解决,亲测可用!
标签:出现 wired pre 异常 img tco mmm alt sys
原文地址:https://www.cnblogs.com/dark-passion/p/10709625.html