When doing the SSM project, encounter an exception thrown by MyBatis:
Mapped Statements collection does not contain value for org.lyk.vo.mapping.NewsNS.findById.
2017-09-01 21:03:48,979 INFO [Org.springframework.context.support.ClassPathXmlApplicationContext]-refreshing org[ Email protected]108d02eb:startup Date [Fri Sep 21:03:48 CST 2017]; Root of context hierarchy2017-09-01 21:03:49,019 INFO [Org.springframework.beans.factory.xml.XmlBeanDefinitionReader ]-Loading XML bean definitions from class path resource [applicationcontext.xml]2017-09-01 21:03:49,352 INFO [org.spring Framework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor]-JSR-330 ' javax.inject.Inject ' Annotation found and supported for autowiring2017-09-01 21:03:49,433 INFO [Com.mchange.v2.log.MLog]-Mlog clients using L og4j logging.2017-09-01 21:03:49,523 INFO [com.mchange.v2.c3p0.C3P0Registry]-Initializing c3p0-0.9.1.2 [built 21- May-2007 15:04:56; Debug? True trace:10]2017-09-01 21:03:49,736 INFO [Com.mchange.v2.c3p0.impl.AbstractPoolBackedDataSource]-Initializing c3p0 Pool ... com.mchange.v2.c3p0.ComboPooledDataSource [acquireincrement-3, AcquIreretryattempts, Acquireretrydelay, Autocommitonclose, False, Automatictesttable, Bre Akafteracquirefailure, False, Checkouttimeout-0, connectioncustomizerclassname-NULL, Connectiontesterclassname, Com.mchange.v2.c3p0.impl.DefaultConnectionTester, DataSourceName 4MDHS29QH2PJH31T4WEOT|429D486D, Debugunreturnedconnectionstacktraces, false, description, NULL, Driverclass -Com.mysql.jdbc.Driver, factoryclasslocation, NULL, Forceignoreunresolvedtransactions-FALSE, Identitytoken, 4mdhs29qh2pjh31t4weot|429d486d, Idleconnectiontestperiod, 0, Initialpoolsize, JDBCURL JDBC:MYSQL://LOCALHOST:3306/MLDN, Maxadministrativetasktime, 0, maxconnectionage, 0, MaxIdleTime Maxidletimeexcessconnections, 0, Maxpoolsize, maxstatements, 0, Maxstatementsperconnection 0, Minpoolsize, 5, Numhelperthreads, 3, NumthreadsawaitingcheckoutdefaultusEr-, 0, Preferredtestquery-NULL, properties---{user=******, password=******}, propertycycle-0, Testcon Nectiononcheckin, False, Testconnectiononcheckout, false, Unreturnedconnectiontimeout-0, Usestraditionalreflectiveproxies-False]2017-09-01 21:03:49,968 INFO [ Org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping]-Mapped "{[/pages/member/ Insert],methods=[],params=[],headers=[],consumes=[],produces=[],custom=[]} "onto public Org.springframework.web.portlet.ModelAndView Org.lyk.action.MemberAction.insert () 2017-09-01 21:03:50,060 INFO [ Org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter]-Looking for @ Controlleradvice:org[email protected]108d02eb:startup Date [Fri Sep 21:03:48 CST 2017]; Root of context hierarchy2017-09-01 21:03:50,099 INFO [ Org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter]-Looking for @ Controlleradvice:org[email protEcted]108d02eb:startup Date [Fri Sep 21:03:48 CST 2017]; Root of context hierarchy2017-09-01 21:03:50,147 INFO [ Org.springframework.web.servlet.handler.SimpleUrlHandlerMapping]-Mapped URL path [/**] onto handler ' Org.springframework.web.servlet.resource.defaultservlethttprequesthandler#0 ' Org.mybatis.spring.MyBatisSystemException:nested exception is org.apache.ibatis.exceptions.PersistenceException: # # # Error querying database. Cause:java.lang.IllegalArgumentException:Mapped Statements collection does not contain value for org.lyk.vo.mapping.newsns.findbyid### Cause:java.lang.IllegalArgumentException:Mapped Statements Collection does Not contain value of org.lyk.vo.mapping.NewsNS.findById at Org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible (mybatisexceptiontranslator.java:75) At Org.mybatis.spring.sqlsessiontemplate$sqlsessioninterceptor.invoke (sqlsessiontemplate.java:368) at Com.sun.proxy. $Proxy 12.selectOne (Unknown Source) at Org.mybatiS.spring.sqlsessiontemplate.selectone (sqlsessiontemplate.java:163) at Org.lyk.dao.impl.NewsDAOImpl.findById ( NEWSDAOIMPL.JAVA:60) at Org.lyk.dao.impl.NewsDAOImpl.findById (newsdaoimpl.java:1) at Org.lyk.service.impl.NewsServiceImpl.get (newsserviceimpl.java:57) at Org.lyk.main.Hello.main (hello.java:37) caused by:org.apache.ibatis.exceptions.PersistenceException: # # # Error querying database. Cause:java.lang.IllegalArgumentException:Mapped Statements collection does not contain value for org.lyk.vo.mapping.newsns.findbyid### Cause:java.lang.IllegalArgumentException:Mapped Statements Collection does Not contain value of org.lyk.vo.mapping.NewsNS.findById at Org.apache.ibatis.exceptions.ExceptionFactory.wrapException (exceptionfactory.java:23) at Org.apache.ibatis.session.defaults.DefaultSqlSession.selectList (defaultsqlsession.java:107) at Org.apache.ibatis.session.defaults.DefaultSqlSession.selectList (defaultsqlsession.java:98) at Org.apache.ibatis.session.defaulTs. Defaultsqlsession.selectone (defaultsqlsession.java:62) 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:358) ... 6 morecaused by:java.lang.IllegalArgumentException:Mapped Statements collection does not contain value for org.lyk.vo.ma Pping. Newsns.findbyid at Org.apache.ibatis.session.configuration$strictmap.get (configuration.java:791) at Org.apache.ibatis.session.Configuration.getMappedStatement (configuration.java:631) at Org.apache.ibatis.session.Configuration.getMappedStatement (configuration.java:624) at Org.apache.ibatis.session.defaults.DefaultSqlSession.selectList (defaultsqlsession.java:103) ... More
The root cause is that the Mybatis.cfg.xml configuration file is missing a reference to Mapper.xml. This problem can be resolved by adding the following configuration.
https://stackoverflow.com/questions/14219558/ Mybatis-illegalargumentexception-mapped-statements-collection-does-not-contain
PS: This problem may also be due to the fact that the operation is not defined in the mapper file.
Mapped Statements collection does not contain value for problem resolution