当前位置:   article > 正文

JPA @PostPersist 和@PreUpdate回调函数中无法注入Bean得解决方案_@postupdate use bean

@postupdate use bean
@Autowired
static private TeacherService teacherService;

@Autowired
static private TestService testService;

@Autowired
public void init(TeacherService teacherService, TestService testService) {
    TeacherListener.teacherService = teacherService;
    TeacherListener.testService = testService;
}

 

声明static私有变量,再在方法上@AutoWired注入,最后私有变量赋值。OK,搞定

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/article/detail/55941
推荐阅读
相关标签
  

闽ICP备14008679号