was not registered for synchronization because synchronization is not active错误
Posted lihuanliu
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了was not registered for synchronization because synchronization is not active错误相关的知识,希望对你有一定的参考价值。
Creating a new SqlSession SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@40f1874e] was not registered for synchronization because synchronization is not active Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@40f1874e] org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException: ### Error querying database. Cause: java.lang.NullPointerException ### Cause: java.lang.NullPointerException at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:79) at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:447) at com.sun.proxy.$Proxy23.selectList(Unknown Source) at org.mybatis.spring.SqlSessionTemplate.selectList(SqlSessionTemplate.java:231) at org.apache.ibatis.binding.MapperMethod.executeForMany(MapperMethod.java:122) at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:64) at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:53) at com.sun.proxy.$Proxy24.queryOrders(Unknown Source) at com.mopon.app.service.impl.OrderServiceImpl.orderExport(OrderServiceImpl.java:798) at com.mopon.app.service.impl.OrderServiceImpl$$FastClassBySpringCGLIB$$75e6b341.invoke(<generated>) at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:669) at com.mopon.app.service.impl.OrderServiceImpl$$EnhancerBySpringCGLIB$$6c3d4ea2.orderExport(<generated>) at com.mopon.app.thread.export.ExportOrderThreadHelper.run(ExportOrderThreadHelper.java:36) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745) Caused by: org.apache.ibatis.exceptions.PersistenceException: ### Error querying database. Cause: java.lang.NullPointerException ### Cause: java.lang.NullPointerException at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:30) at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:122) at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:113) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:497) at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:434) ... 15 more Caused by: java.lang.NullPointerException at com.mopon.app.dto.RequestOrderDTO.getLimitNum(RequestOrderDTO.java:167) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:497) at org.apache.ibatis.reflection.invoker.MethodInvoker.invoke(MethodInvoker.java:41) at org.apache.ibatis.reflection.wrapper.BeanWrapper.getBeanProperty(BeanWrapper.java:164) at org.apache.ibatis.reflection.wrapper.BeanWrapper.get(BeanWrapper.java:49) at org.apache.ibatis.reflection.MetaObject.getValue(MetaObject.java:122) at org.apache.ibatis.scripting.xmltags.DynamicContext$ContextMap.get(DynamicContext.java:94) at org.apache.ibatis.scripting.xmltags.DynamicContext$ContextAccessor.getProperty(DynamicContext.java:108) at org.apache.ibatis.ognl.OgnlRuntime.getProperty(OgnlRuntime.java:2420) at org.apache.ibatis.ognl.ASTProperty.getValueBody(ASTProperty.java:114) at org.apache.ibatis.ognl.SimpleNode.evaluateGetValueBody(SimpleNode.java:212) at org.apache.ibatis.ognl.SimpleNode.getValue(SimpleNode.java:258) at org.apache.ibatis.ognl.ASTNotEq.getValueBody(ASTNotEq.java:50) at org.apache.ibatis.ognl.SimpleNode.evaluateGetValueBody(SimpleNode.java:212) at org.apache.ibatis.ognl.SimpleNode.getValue(SimpleNode.java:258) at org.apache.ibatis.ognl.ASTAnd.getValueBody(ASTAnd.java:61) at org.apache.ibatis.ognl.SimpleNode.evaluateGetValueBody(SimpleNode.java:212) at org.apache.ibatis.ognl.SimpleNode.getValue(SimpleNode.java:258) at org.apache.ibatis.ognl.Ognl.getValue(Ognl.java:494) at org.apache.ibatis.ognl.Ognl.getValue(Ognl.java:458) at org.apache.ibatis.scripting.xmltags.OgnlCache.getValue(OgnlCache.java:44) at org.apache.ibatis.scripting.xmltags.ExpressionEvaluator.evaluateBoolean(ExpressionEvaluator.java:32) at org.apache.ibatis.scripting.xmltags.IfSqlNode.apply(IfSqlNode.java:34) at org.apache.ibatis.scripting.xmltags.MixedSqlNode.apply(MixedSqlNode.java:33) at org.apache.ibatis.scripting.xmltags.DynamicSqlSource.getBoundSql(DynamicSqlSource.java:41) at org.apache.ibatis.mapping.MappedStatement.getBoundSql(MappedStatement.java:279) at com.github.pagehelper.PageInterceptor.intercept(PageInterceptor.java:82) at org.apache.ibatis.plugin.Plugin.invoke(Plugin.java:61) at com.sun.proxy.$Proxy49.query(Unknown Source) at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:120) ... 21 more Creating a new SqlSession SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@4edbc355] was not registered for synchronization because synchronization is not active 2019-09-11 10:45:54.740 [DEBUG][o.s.jdbc.datasource.DataSourceUtils][mod_order][null][null][null][null][null] Fetching JDBC Connection from DataSource JDBC Connection [com.alibaba.druid.proxy.jdbc.ConnectionProxyImpl@53c08195] will not be managed by Spring
错误来源代码展示:
1、mybatis的配置文件
<select id="queryOrders" parameterType="com.RequestOrderDTO" resultMap="queryOrdersResultMap">
2、RequestOrderDTO 对应的部分字段和getter、setter方法
/* 仅仅导出使用: 每次取的数量*/ private int limitSize; /* 仅仅导出使用: 第几次取 */ private int limitNum; public int getLimitSize() return limitSize; public void setLimitSize(int limitSize) this.limitSize = limitSize; public int getLimitNum() return limitNum; public void setLimitNum(int limitNum) this.limitNum = limitNum;
当这么定义变量和getter、setter方法时,mybatis就会报这个错误。
即变量的类型不能用原始类型,必须用封装类型。
===改成这样就好了===
/* 仅仅导出使用: 每次取的数量*/ private Integer limitSize; /* 仅仅导出使用: 第几次取 */ private Integer limitNum; public Integer getLimitSize() return limitSize; public void setLimitSize(Integer limitSize) this.limitSize = limitSize; public Integer getLimitNum() return limitNum; public void setLimitNum(Integer limitNum) this.limitNum = limitNum;
问题的原理没找,欢迎路过的有见地的一起分享。
以上是关于was not registered for synchronization because synchronization is not active错误的主要内容,如果未能解决你的问题,请参考以下文章
异常Assembly location for Razor SDK Tasks was not specified
iOS错误之“A valid provisioning profile for this executable was not found”
python version 2.7 required,which was not found in the registry
zabbix--邮件告警报错“Support for SMTP authentication was not compiled in”
zabbix--邮件告警报错“Support for SMTP authentication was not compiled in”
App installation failed (A valid provisioning profile for this executable was not found)