处理Mybatis框架的时候,出现下面错误时Error querying database. Cause: java.lang.IllegalArgumentException: Mapped Sta

Error querying database. Cause: java.lang.IllegalArgumentException: Mapped Statements collection does not contain value for mapper.UserMapper.selAll ### Cause: java.lang.IllegalArgumentException: Mapped Statements collection does not contain value for mapper.UserMapper.selAll 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 org.apache.ibatis.session.defaults.DefaultSqlSession.selectOne(DefaultSqlSession.java:61) at com.zyq.mapper.impl.UserMapperImpl.selAll(UserMapperImpl.java:27) at test.TestM.main(TestM.java:17) Caused by: java.lang.IllegalArgumentException: Mapped Statements collection does not contain value for mapper.UserMapper.selAll 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) … 5 more## 标题


在处理调用SQL方法时如下面selectOne(“com.zyq.mapper.UserMapper.selAll”);

inputStream=Resources.getResourceAsStream(strxml);
            sqlSessionFactory=new SqlSessionFactoryBuilder().build(inputStream);
            sqlSession=sqlSessionFactory.openSession();
            //一定要写方法的全类名
            int count=sqlSession.selectOne("com.zyq.mapper.UserMapper.selAll");代码片
``

`
//这里要写全类名,不能mapper.UserMapper.selAll这样写,要把包名com.zyq 写上,这样就可以啦com.zyq.mapper.UserMapper.selAll

这里需要在mapper接口中有具体对应的方法,

posted @ 2021-01-02 20:17  King-DA  阅读(1289)  评论(0编辑  收藏  举报