我的环境是 Tomcat + Spring MVC + Spring + Sping jdbc我在Action中开启了一个线程,线程里 有 自动注入的接口 但是 用哪个接口的时候 报空指针 不知道为什么 ?求解Action 部分代码
@RequestMapping(value="/runCase.do")
public String ExecCase(Model model ,String [] CaseList , HttpServletRequest request,HttpServletResponse response){
logger.info("runCase.do is running..............................");
//生成Group_id 并且存入session中
String groupId = TimeUtils.makeGroupID();
HttpSession session =request.getSession();
session.setAttribute("StrGroupId", groupId);
testThread t1 = new testThread();
t1.start();
logger.info("The end of the process..................................");
return "redirect:/viewResults.do";
}
@Resource
public class testThread extends Thread{
@Autowired
private IDataLoadService dls /*= new DataLoadService()*/;
public testThread(){
System.out.println("testThread init () ..............................................");
}
@Override
public void run() {
dls.loadSystemParameter();
}
}
@RequestMapping(value="/runCase.do")
public String ExecCase(Model model ,String [] CaseList , HttpServletRequest request,HttpServletResponse response){
logger.info("runCase.do is running..............................");
//生成Group_id 并且存入session中
String groupId = TimeUtils.makeGroupID();
HttpSession session =request.getSession();
session.setAttribute("StrGroupId", groupId);
testThread t1 = new testThread();
t1.start();
logger.info("The end of the process..................................");
return "redirect:/viewResults.do";
}
@Resource
public class testThread extends Thread{
@Autowired
private IDataLoadService dls /*= new DataLoadService()*/;
public testThread(){
System.out.println("testThread init () ..............................................");
}
@Override
public void run() {
dls.loadSystemParameter();
}
}
testThread t1 = new testThread();
.
虽然我没用过spring,但是看到这句,你是自己new的,而不是通过spring的bean容器获取的对象,spring怎么给你注入?
不就是让Spring 管理 那个类吗?