Because mybaits is not configured, SqlSession was not registered for synchronization is abnormal. mybaitssqlsession

Source: Internet
Author: User
Tags reflector

Because mybaits is not configured, SqlSession was not registered for synchronization is abnormal. mybaitssqlsession

A message is reported when you run the program today.

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]

The exception is handled in a centralized manner, so I reported this error. After checking for half a day, the online results all indicate that the configuration file is incorrect, but my project configuration file must be correct, because the project has been developed for a long time, I only reported this error when I wrote a method today, so the configuration file error is excluded, but the method I wrote should be fine, it was written in the past.

I couldn't find the cause on the Internet for a long time. I had to look at my own program and print out the exception of my method. I did not concentrate on it first, and then the exception came out:

Org. mybatis. spring. MyBatisSystemException: nested exception is org. apache. ibatis. reflection. ReflectionException: There is no getter for property named 'demotid' 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.exe cute (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 'demotid' 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.exe cutor. 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

Based on this exception, check the program again, find the problem occurs in the departid parameter, then check the source program, and find that the SQL statement of the method I wrote is in mapper. the xml file references the departid parameter to determine whether it is null or null. Therefore, There is no getter for property named 'demotid' in 'class java. lang. string 'exception.

Solution: 1. Add the param parameter identifier when passing parameters in the method, for example, countNum (@ Param ("departid") String departid );

2. Replace parameters with map or objects when passing parameters through methods.

I hope this article can solve these problems. Thank you for your support!

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.