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