来大神帮看下
package org.easyworld.function.user.userIndex.action;
import java.util.List;
import java.util.Map;
import org.easyworld.function.user.userIndex.service.UserIndexService;
public class MyThread extends Thread {
private UserIndexService userIndexService;
public UserIndexService getUserIndexService() {
return userIndexService;
}
public void setUserIndexService(UserIndexService userIndexService) {
this.userIndexService = userIndexService;
}
public void run(){
while(!this.isInterrupted()){
try{
Thread.sleep(30000);
}catch(InterruptedException e){
e.printStackTrace();
}
//此处
空指针
Map<String,Object> map = userIndexService.checkGoods();
//如果单独输出aaa 则是正常的
//System.out.println("aaa");
}
}
}
Service 里面
public Map<String,Object> checkGoods(){
Map<String,Object> map = new HashMap<String, Object>();
List<Map<String, Object>> list = queryForList("userIndex.check_goods");
map.put("list", list);
return map;
}
异常
Exception in thread "Thread-4"
java.lang.NullPointerException
at org.easyworld.function.user.userIndex.action.MyThread.run(MyThread.java:26)
求大神帮看看出错的地方在哪 可能是Spring的注入有问题,但是同一个包下别的类中 注入是正常的
------解决方案--------------------那就是没注入
------解决方案--------------------userIndexService为null
------解决方案--------------------userIndexService为空,看看配置是否有问题。
------解决方案--------------------