1:@Autowired
@Autowired
private OssService ossService;
2:在类的构造方法中给定义的接口赋值
// set 注入service
private EduSubjectService eduSubjectService;
// 因为此类没有spring 管理,所以只能这种方式注入eduSubjectService
public EduExcelListener(EduSubjectService eduSubjectService) {
this.eduSubjectService = eduSubjectService;
}
在new对象时候把接口传进来
new EduExcelListener(eduSubjectService)