程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 數據庫知識 >> 其他數據庫知識 >> MSSQL >> mybaits非設置裝備擺設緣由,招致SqlSession was not registered for synchronization異常

mybaits非設置裝備擺設緣由,招致SqlSession was not registered for synchronization異常

編輯:MSSQL

mybaits非設置裝備擺設緣由,招致SqlSession was not registered for synchronization異常。本站提示廣大學習愛好者:(mybaits非設置裝備擺設緣由,招致SqlSession was not registered for synchronization異常)文章只能為提供參考,不一定能成為您想要的結果。以下是mybaits非設置裝備擺設緣由,招致SqlSession was not registered for synchronization異常正文


明天運轉法式時報了

SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@69d4fb43] was not registered for synchronization because synchronization is not active

[11:03:17]-Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@69d4fb43]

因為異常是集中處置的,所以報了如許的毛病,查了半天,網上成果都是說設置裝備擺設文件失足的,可是我的項目設置裝備擺設文件確定是沒錯的,由於項目都開辟了好長時光了,只是我明天寫了個辦法才報的這個毛病,所以消除設置裝備擺設文件失足,可是我寫的辦法應當沒成績的,之前也如許寫的呀。

      網上查半天沒找到緣由,沒方法,只能看看本身的法式了,把本身寫的辦法異常直接打印出來,先不集中處置,然後異常出來了:

org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.reflection.ReflectionException: There is no getter for property named ‘departid‘ in ‘class java.lang.String‘

 at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:75)

 at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:371)

 at com.sun.proxy.$Proxy15.selectOne(Unknown Source)

 at org.mybatis.spring.SqlSessionTemplate.selectOne(SqlSessionTemplate.java:163)

 at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:68)

 at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:52)

 at com.sun.proxy.$Proxy125.selectCount(Unknown Source)

 at com.sinog2c.service.impl.yzgl.TbyzScoreServiceImpl.selectCount(TbyzScoreServiceImpl.java:66)

 at com.sinog2c.mvc.controller.yzgl.criminalexam.JifenController.getLastMonthScoreList(JifenController.java:76)

 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

 at java.lang.reflect.Method.invoke(Method.java:597)

 at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:175)

 at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:446)

 at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:434)

 at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:938)

 at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:870)

 at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:961)

 at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:852)

 at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)

 at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:837)

 at javax.servlet.http.HttpServlet.service(HttpServlet.java:723)

 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)

 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)

 at com.alibaba.druid.support.http.WebStatFilter.doFilter(WebStatFilter.java:124)

 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)

 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)

 at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)

 at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)

 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)

 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)

 at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)

 at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)

 at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)

 at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)

 at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)

 at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)

 at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:861)

 at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:606)

 at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)

 at java.lang.Thread.run(Thread.java:662)

Caused by: org.apache.ibatis.reflection.ReflectionException: There is no getter for property named ‘departid‘ in ‘class java.lang.String‘

 at org.apache.ibatis.reflection.Reflector.getGetInvoker(Reflector.java:380)

 at org.apache.ibatis.reflection.MetaClass.getGetInvoker(MetaClass.java:170)

 at org.apache.ibatis.reflection.wrapper.BeanWrapper.getBeanProperty(BeanWrapper.java:152)

 at org.apache.ibatis.reflection.wrapper.BeanWrapper.get(BeanWrapper.java:48)

 at org.apache.ibatis.reflection.MetaObject.getValue(MetaObject.java:116)

 at org.apache.ibatis.scripting.xmltags.DynamicContext$ContextMap.get(DynamicContext.java:97)

 at org.apache.ibatis.scripting.xmltags.DynamicContext$ContextAccessor.getProperty(DynamicContext.java:116)

 at org.apache.ibatis.ognl.OgnlRuntime.getProperty(OgnlRuntime.java:1657)

 at org.apache.ibatis.ognl.ASTProperty.getValueBody(ASTProperty.java:92)

 at org.apache.ibatis.ognl.SimpleNode.evaluateGetValueBody(SimpleNode.java:170)

 at org.apache.ibatis.ognl.SimpleNode.getValue(SimpleNode.java:210)

 at org.apache.ibatis.ognl.ASTNotEq.getValueBody(ASTNotEq.java:49)

 at org.apache.ibatis.ognl.SimpleNode.evaluateGetValueBody(SimpleNode.java:170)

 at org.apache.ibatis.ognl.SimpleNode.getValue(SimpleNode.java:210)

 at org.apache.ibatis.ognl.ASTAnd.getValueBody(ASTAnd.java:56)

 at org.apache.ibatis.ognl.SimpleNode.evaluateGetValueBody(SimpleNode.java:170)

 at org.apache.ibatis.ognl.SimpleNode.getValue(SimpleNode.java:210)

 at org.apache.ibatis.ognl.Ognl.getValue(Ognl.java:333)

 at org.apache.ibatis.ognl.Ognl.getValue(Ognl.java:413)

 at org.apache.ibatis.ognl.Ognl.getValue(Ognl.java:395)

 at org.apache.ibatis.scripting.xmltags.OgnlCache.getValue(OgnlCache.java:48)

 at org.apache.ibatis.scripting.xmltags.ExpressionEvaluator.evaluateBoolean(ExpressionEvaluator.java:32)

 at org.apache.ibatis.scripting.xmltags.IfSqlNode.apply(IfSqlNode.java:33)

 at org.apache.ibatis.scripting.xmltags.MixedSqlNode.apply(MixedSqlNode.java:32)

 at org.apache.ibatis.scripting.xmltags.DynamicSqlSource.getBoundSql(DynamicSqlSource.java:40)

 at org.apache.ibatis.mapping.MappedStatement.getBoundSql(MappedStatement.java:278)

 at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:75)

 at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:108)

 at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:102)

 at org.apache.ibatis.session.defaults.DefaultSqlSession.selectOne(DefaultSqlSession.java:66)

 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

 at java.lang.reflect.Method.invoke(Method.java:597)

 at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:358)

 ... 40 more

依據這個異常再查法式,發明成績湧現在departid這個參數,再查源法式,發明本來我寫的誰人辦法的sql在mapper.xml文件裡援用了對參數departid停止斷定能否為null或空,所以才報 There is no getter for property named ‘departid‘ in ‘class java.lang.String‘異常。

處理辦法:1、在辦法傳參時,加param參數標識,如:countNum(@Param("departid")String departid);

                  2、在辦法傳參時,把參數換成map或對象。

願望經由過程此文能處理這類成績,感謝年夜家對本站的支撐!

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved