来大神帮看下

mty 2013-07-08 12:53:30
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的注入有问题,但是同一个包下别的类中 注入是正常的
...全文
122 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
菖蒲老先生 2013-07-08
  • 打赏
  • 举报
回复
跟方法checkGoods没有关系, userIndexService = null了, 重新注入或者new一个。。。
shiyonghu 2013-07-08
  • 打赏
  • 举报
回复
Map<String,Object> map = userIndexService.checkGoods();中userIndexService为空,所以看一下配置文件
  • 打赏
  • 举报
回复
userIndexService为空,看看配置是否有问题。
1991_蚂蚁 2013-07-08
  • 打赏
  • 举报
回复
userIndexService为null
ZHOU西口 2013-07-08
  • 打赏
  • 举报
回复
那就是没注入
mty 2013-07-08
  • 打赏
  • 举报
回复
没有人吗,在线等大神

67,513

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧