写了个多线程方法,多线程因为是new的自动注入不进去,
我想放到其他类中,然后多线程调用这个static方法,但还是注入不进去,怎么办啊?
@Component
public class DaoTemp {
private static MapperA a;
@Autowired
public static void setA(MapperA a) {
DaoTemp.a = a;
}
static List<PageData> aaa(String number, PageData pd){
List<PageData> list ;
switch (number){
case "0" : list = a.listAll(pd);break;
case "1" : list = a.listAll1(pd);break;
case "2" : list = a.listAll2(pd);break;
case "3" : list = a.listAll3(pd);break;
default:
throw new IllegalStateException("Unexpected value: " + number);
}
return list;
}
}