Mybatis:Mapped Statements collection does not contain value for
2018-02-22 14:47
435 查看
bug:使用Mybatis时,报错;
原因:以下映射sql的标识字符串和Samplemapper.xml中的namespace()不一致;之前都是手写的namespace,命名的时候,使用的是mapper.xml的目录,这次是用工具自动生成的mapper.xml,namespace命名是用的dao目录;
Exception in thread "main" org.apache.ibatis.exceptions.PersistenceException: ### Error querying database. Cause: java.lang.IllegalArgumentException: Mapped Statements collection does not contain value for mycom.mapping.SampleMapper.selectByPrimaryKey ### Cause: java.lang.IllegalArgumentException: Mapped Statements collection does not contain value for mycom.mapping.SampleMapper.selectByPrimaryKey at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:26) at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:111) at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:102) at org.apache.ibatis.session.defaults.DefaultSqlSession.selectOne(DefaultSqlSession.java:66) at mycom.test.mybatis.test.MybatisTest.main(MybatisTest.java:43) Caused by: java.lang.IllegalArgumentException: Mapped Statements collection does not contain value for mycom.mapping.SampleMapper.selectByPrimaryKey at org.apache.ibatis.session.Configuration$StrictMap.get(Configuration.java:797) 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:107) ... 3 more
原因:以下映射sql的标识字符串和Samplemapper.xml中的namespace()不一致;之前都是手写的namespace,命名的时候,使用的是mapper.xml的目录,这次是用工具自动生成的mapper.xml,namespace命名是用的dao目录;
String statement2 = "mycom.mapping.SampleMapper.selectByPrimaryKey";//映射sql的标识字符串 Sample result = session.selectOne(statement2, 2); System.out.println(result);
相关文章推荐
- mybatis错误 Mapped Statements collection does not contain value for
- mybatis+springMVC整合出现Mapped Statements collection does not contain value for ***
- mybatis之Mapped Statements collection does not contain value for...错误原因分析
- mybatis 错误 Mapped Statements collection does not contain value for
- Mybatis项目从Eclipse转入Idea无法启动问题 Mapped Statements collection does not contain value for
- Mapped Statements collection does not contain value for com.mybatis_Spring.dao.getAllUsers
- mybatis错误 Mapped Statements collection does not contain value for
- mybatis:java.lang.IllegalArgumentException: Mapped Statements collection does not contain value for
- mybatis错误 Mapped Statements collection does not contain value for
- mybatis 抛出 Mapped Statements collection does not contain value for 异常
- mybatis错误 Mapped Statements collection does not contain value for
- mybatis错误 Mapped Statements collection does not contain value for
- Mapped Statements collection does not contain value for xxxx mybatis xml maven package install
- MyBatis出现java.lang.IllegalArgumentException: Mapped Statements collection does not contain value for
- 使用Maven构建项目,spring整合mybatis发生错误:Mapped Statements collection does not contain value for
- Mybatis 出现Mapped Statements collection does not contain value for xxx
- 【Mybatis】java.lang.IllegalArgumentException: Mapped Statements collection does not contain value for
- MyBatis:Mapped Statements collection does not contain value for xxx
- mybatis错误 Mapped Statements collection does not contain value for
- myBatis配置报Mapped Statements collection does not contain value for