ssh使用 TimerTask空指针错误

J2EE 码拜 8年前 (2016-05-19) 1099次浏览
本人不使用TimerTask,直接运行这个action是成功的,但是使用TimerTask,就一直报空指针的错误。是在Spring里面配置错了吗?
DBConn conn = new DBConn();
Connection connection = conn.buildConnection();
connection.setAutoCommit(false);
String sql = “select id from T_ErrorApply where status =”完成” and nupdatetime between “2000-01-01 00:00:00.000” and “”+y+”-“+m+”-“+d+” “+h+”:”+mi+”:”+s+”.000″”;

PreparedStatement stmt = connection.prepareStatement(sql);
ResultSet rs = stmt.executeQuery();
ArrayList<Long> list = new ArrayList();
while (rs.next()) {
long   result = rs.getLong(“id”);
errorApply = errorApplyService.getById( result); //这句话一直报错,空指针。
errorApply.setComments(“系统默认评价”);
errorApplyService.update(errorApply);
System.out.println( errorApply.getComments());
}
报错的提示:
java.lang.NullPointerException
at com.surfkj.wlgzbx.action.AutoComment2.run(AutoComment2.java:63)
at java.util.TimerThread.mainLoop(Timer.java:512)
at java.util.TimerThread.run(Timer.java:462)

解决方案

40

synchroDataTimerTask 里面没有注入errorApplyService.
加个@Autowired注解试下,不行就在
<bean id=”synchroDataTimerTask” class=”com.surfkj.wlgzbx.action.AutoComment2″></bean>里面把errorApplyService属性加上

40

肯定是  errorApplyService  没注入

CodeBye 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权 , 转载请注明ssh使用 TimerTask空指针错误
喜欢 (0)
[1034331897@qq.com]
分享 (0)