我试图从控制器外部更新表行数据(在一些线程内)并始终获得'NullPointerException'。线程代码:public class S3Thread implements Runnable {@Autowired private IAutomationService automationService;@Overridepublic void run() {
Automation config = new Automation("user1","success");
automationService.updateAutomation(config);
}}在下面行抛出NullPointer异常:automationService.updateAutomation(config);注意:我能够从控制器类创建/更新。仅在Thread中。
4 回答

杨魅力
TA贡献1811条经验 获得超6个赞
Spring不扫描您的runnable,因为它没有使用@ Component注释。尝试使用@ Component / @ Service注释它。不要忘记设置范围所需的范围!
添加回答
举报
0/150
提交
取消