1 public class BaseDataSyncPushJob implements StatefulJob{ 2 3 /*** 日志 */ 4 private static final Log LOG = LogFactory.getLog(BaseDataSyncPushJob.class); 5 6 @Autowired 7 private IJobMappingService jobMappingService; 8 @Autowired 9 private IBaseDataSyncPushService baseDataSyncPushService; 10 11 @Override 12 public void execute(JobExecutionContext context) throws JobExecutionException { 13 // 本地服务器IP值 14 try { 15 //// 本地服务器IP值 16 String hostAddress = HttpClientUtil.getLocalIp(); 17 //打印日志 18 LOG.info("天津邮管局基础信息同步开始:"); 19 JobMappingEntity jobMappingEntity=jobMappingService.queryByIPAndJobtype(hostAddress, JobConstant.JOB_TYPE_TIANFANG_PUSH); 20 //jobMappingEntity的非空校验 21 if(null == jobMappingEntity){ 22 return; 23 } 24 //打印日志 25 LOG.info("获取对象jobMappingEntity:"+jobMappingEntity.toString()); 26 /** 27 * 调用 天津邮管局推送的service 28 */ 29 baseDataSyncPushService.executePushEmp(jobMappingEntity); 30 baseDataSyncPushService.executePushExpressVehicle(jobMappingEntity); 31 baseDataSyncPushService.executePushSalesDepartment(jobMappingEntity); 32 //打印日志 33 LOG.info("天津邮管局基础信息同步完毕"); 34 } catch (Exception e) { 35 //打印堆栈信息 36 LOG.error("天津邮管局基础信息同步抛异常", e); 37 //跑出异常 38 throw new JobExecutionException(e); 39 } 40 } 41 }
Spring报错:
1 [16/12/24 09:05:27:917] ERROR job.BaseDataSyncPushJob: 天津邮管局基础信息同步抛异常 2 org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.builder.xml.IncompleteStatementException: Could not find result map com.deppon.dpap.module.tianfangpush.server.entity.BaseDataSyncPushEntity.baseDataSyncPush 3 at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:73) 4 at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:346) 5 at com.sun.proxy.$Proxy20.selectList(Unknown Source) 6 at org.mybatis.spring.SqlSessionTemplate.selectList(SqlSessionTemplate.java:189) 7 at com.deppon.dpap.module.monitor.server.dao.impl.JobMappingDao.queryByJobMappingEntity(JobMappingDao.java:98) 8 at com.deppon.dpap.module.monitor.server.service.impl.JobMappingService.queryByIPAndJobtype(JobMappingService.java:102) 9 at com.deppon.dpap.module.tianfangpush.server.job.BaseDataSyncPushJob.execute(BaseDataSyncPushJob.java:39) 10 at org.quartz.core.JobRunShell.run(JobRunShell.java:223) 11 at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:549) 12 Caused by: org.apache.ibatis.builder.xml.IncompleteStatementException: Could not find result map com.deppon.dpap.module.tianfangpush.server.entity.BaseDataSyncPushEntity.baseDataSyncPush 13 at org.apache.ibatis.builder.MapperBuilderAssistant.setStatementResultMap(MapperBuilderAssistant.java:283) 14 at org.apache.ibatis.builder.MapperBuilderAssistant.addMappedStatement(MapperBuilderAssistant.java:221) 15 at org.apache.ibatis.builder.xml.XMLStatementBuilder.parseStatementNode(XMLStatementBuilder.java:66) 16 at org.apache.ibatis.session.Configuration.buildAllStatements(Configuration.java:497) 17 at org.apache.ibatis.session.Configuration.getMappedStatement(Configuration.java:434) 18 at org.apache.ibatis.session.Configuration.getMappedStatement(Configuration.java:428) 19 at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:77) 20 at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:72) 21 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 22 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) 23 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 24 at java.lang.reflect.Method.invoke(Method.java:606) 25 at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:338) 26 ... 7 more 27 Caused by: java.lang.IllegalArgumentException: Result Maps collection does not contain value for com.deppon.dpap.module.tianfangpush.server.entity.BaseDataSyncPushEntity.baseDataSyncPush 28 at org.apache.ibatis.session.Configuration$StrictMap.get(Configuration.java:594) 29 at org.apache.ibatis.session.Configuration.getResultMap(Configuration.java:370) 30 at org.apache.ibatis.builder.MapperBuilderAssistant.setStatementResultMap(MapperBuilderAssistant.java:281) 31 ... 19 more
原因不是
JobMappingEntity jobMappingEntity=jobMappingService.queryByIPAndJobtype(hostAddress, JobConstant.JOB_TYPE_TIANFANG_PUSH);
这行,而是由于整个类生产代理的过程中出现报错,
检查发现是:
baseDataSyncPushService.executePushEmp(jobMappingEntity);
baseDataSyncPushService.executePushExpressVehicle(jobMappingEntity);
baseDataSyncPushService.executePushSalesDepartment(jobMappingEntity);
这三行 mybaties文件resultMap写错导致的