Mapped Statements collection does not contain value for 问题的解决

在做SSM项目的时候,遇到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 01 21:03:48 CST 2017]; root of context hierarchy
2017-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.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor] - JSR-330 ‘javax.inject.Inject‘ annotation found and supported for autowiring
2017-09-01 21:03:49,433 INFO [com.mchange.v2.log.MLog] - MLog clients using log4j 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 -> 30, acquireRetryDelay -> 1000, autoCommitOnClose -> false, automaticTestTable -> null, breakAfterAcquireFailure -> 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 -> 10, jdbcUrl -> jdbc:mysql://localhost:3306/mldn, maxAdministrativeTaskTime -> 0, maxConnectionAge -> 0, maxIdleTime -> 1000, maxIdleTimeExcessConnections -> 0, maxPoolSize -> 20, maxStatements -> 0, maxStatementsPerConnection -> 0, minPoolSize -> 5, numHelperThreads -> 3, numThreadsAwaitingCheckoutDefaultUser -> 0, preferredTestQuery -> null, properties -> {user=******, password=******}, propertyCycle -> 0, testConnectionOnCheckin -> 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 01 21:03:48 CST 2017]; root of context hierarchy
2017-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 01 21:03:48 CST 2017]; root of context hierarchy
2017-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 for 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.$Proxy12.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 for 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 more
Caused by: java.lang.IllegalArgumentException: Mapped Statements collection does not contain value for org.lyk.vo.mapping.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)
    ... 13 more

根本原因是mybatis.cfg.xml配置文件缺少了对Mapper.xml的引用。增加如下配置就可以解决该问题了。

https://stackoverflow.com/questions/14219558/mybatis-illegalargumentexception-mapped-statements-collection-does-not-contain

PS: 该问题也有可能是由于mapper文件里面没有定义该操作。

时间: 2024-12-08 22:36:19

Mapped Statements collection does not contain value for 问题的解决的相关文章

java.lang.IllegalArgumentException: XXX is ambiguous in Mapped Statements collection

问题的出现: 在后台添加一个新栏目的时候,照着程序已有原来的代码添加新的功能时,文件没有错误.点击新的栏目的时候报了java.lang.IllegalArgumentException: selectPageByExample is ambiguous in Mapped Statements collection (try using the full name including the namespace, or rename one of the entries). 解决: 在网上查找了

【原创】Mapped Statements collection does not contain value for DaoImpl.method

问题: org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException: ### Error updating database. Cause: java.lang.IllegalArgumentException: Mapped Statements collection does not contain value for com.

Mapped Statements collection does not contain value for

Mapped Statements collection does not contain value for后面是什么类什么方法之类的: 错误原因有几种: 1.mapper.xml中没有加入namespace 2.mapper.xml中的方法和接口mapper的方法不对应 3.mapper.xml没有加入到mybatis-config.xml中(即总的配置文件),例外:配置了mapper文件的包路径的除外 4.mapper.xml文件名和所写的mapper名称不相同.

Mapped Statements collection already contains value for

解决了! 参考的网址:http://www.cnblogs.com/langtianya/archive/2013/03/18/2966491.html 错误原因是由于使用ibatis的F554281Mapper.xml实现接口F554281Mapper.java中的方法的时候的id有重复的值,比如 <select id="find81OrderBySovr01" resultMap="81ResultMap" parameterType="java

Mapped Statements collection does not contain value fo

Mapped Statements collection does not contain value for后面是什么类什么方法之类的: 错误原因有几种: 1.mapper.xml中没有加入namespace 2.mapper.xml中的方法和接口mapper的方法不对应 3.mapper.xml没有加入到mybatis-config.xml中(即总的配置文件),例外:配置了mapper文件的包路径的除外 4.mapper.xml文件名和所写的mapper名称不相同.

mybatis报错Mapped Statements collection does not contain value for com.inter.IOper

首页 > 精品文库 > mybatis报错Mapped Statements collection does not contain value for com.inter.IOper mybatis报错Mapped Statements collection does not contain value for com.inter.IOper 2015-04-09 浏览(52) [摘要:正在顺序挪用IOperation接心中的getAllItems方式时,涌现了以下毛病: Exception

Mybatis_IllegalArgumentException: Mapped Statements collection does not contain value for

java.lang.IllegalArgumentException: Mapped Statements collection does not contain value for queryAllUser 可能原因是:resources路径下,mybatis-conf.xml中缺少了对应的mapper <mapper resource="com/bruce/geekway/model/xml/DemoMapper.xml" /> 另外需要注意: 1,

MyBatis:Mapped Statements collection does not contain value for xxx

完整错误信息: 十一月 03, 2015 10:01:08 上午 org.apache.catalina.core.StandardWrapperValve invoke 严重: Servlet.service() for servlet [springmvc] in context with path [/xinghe-platform-web] threw exception [Request processing failed; nested exception is org.mybati

Error querying database. Cause: java.lang.IllegalArgumentException: Mapped Statements collection does not contain value for &hellip;

编译通过并且运行web成功后,访问的页面不需要连接数据库,不牵扯到反射调用实体类就不会报错, 报错内容如下: [WARNING] org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exce