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

 

Error source code shows:

1, mybatis profile

<select id="queryOrders" parameterType="com.RequestOrderDTO" resultMap="queryOrdersResultMap">

2, RequestOrderDTO corresponding part of the field and getter, setter methods

    / * Just derived using: time to take the number of * / 
    Private  int LimitSize;
     / * only export used: taking the first few times * / 
    Private  int limitNum; 
    
    public  int getLimitSize () {
         return LimitSize; 
    } 

    public  void setLimitSize ( int LimitSize) {
         the this .limitSize = LimitSize; 
    } 

    public  int getLimitNum () {
         return limitNum; 
    } 

    public  void setLimitNum ( int limitNum) {
         the this.limitNum = limitNum; 
    }

When so defined variables and getter, setter methods, mybatis will report this error.

That type of the variable can not primitives , must package type .

 

That's all changed === ===

    / * Just derived using: time to take the number of * / 
    Private Integer LimitSize;
     / * only export used: taking the first few times * / 
    Private Integer limitNum; 

    public Integer getLimitSize () {
         return LimitSize; 
    } 

    public  void setLimitSize (LimitSize Integer) {
         the this .limitSize = LimitSize; 
    } 

    public Integer getLimitNum () {
         return limitNum; 
    } 

    public  void setLimitNum (Integer limitNum) {
         the this .limitNum = limitNum; 
    }

 

 

Principle did not find the problem, welcomed the passing insightful share.

 

Guess you like

Origin www.cnblogs.com/lihuanliu/p/11505026.html