Error:
org.apache.ibatis.exceptions.PersistenceException:
### Error querying database. Cause: java.lang. IllegalArgumentException: Mapped Statements collection does not contain value for com.helloword.mapper.UserMapper.xml
### Cause: java.lang. IllegalArgumentException: Mapped Statements collection does not contain value for com.helloword.mapper.UserMapper.xml
at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:30)
at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:150)
at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:141)
at org.apache.ibatis.session.defaults.DefaultSqlSession.selectOne(DefaultSqlSession.java:77)
at org.apache.ibatis.session.defaults.DefaultSqlSession.selectOne(DefaultSqlSession.java:71)
at test.Test.main(Test.java:43)
Caused by: java.lang. IllegalArgumentException: Mapped Statements collection does not contain value for com.helloword.mapper.UserMapper.xml
at org.apache.ibatis.session.Configuration$StrictMap.get(Configuration.java:888)
at org.apache.ibatis.session.Configuration.getMappedStatement(Configuration.java:721)
at org.apache.ibatis.session.Configuration.getMappedStatement(Configuration.java:714)
at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:147)
… 4 more
Solution.
See the error message, guess that it may be because there is a problem with the configuration file, first see if the <mapper> configuration in mybatis-config.xml is correct, see if there is no problem with the <mapper> configuration see if the path of namespace in UserMapper.xml is correct, check if there is no problem with UerMapper. xml is in the package of com.helloword.mapper, but this package is empty. Move the mapping file of UserMapper.xml to the package of entity class, and modify the configuration in one and two. After testing, the above error is still reported.
New error message
org.apache.ibatis.exceptions.PersistenceException:
### Error building SqlSession.
### The error may exist in com/helloworld/model/UserMapper.xml
### Cause: org.apache.ibatis.builder. BuilderException: Error parsing SQL Mapper Configuration. Cause: java.io. IOException: Could not find resource com/helloworld/model/UserMapper.xml
at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:30)
at org.apache.ibatis.session.SqlSessionFactoryBuilder.build(SqlSessionFactoryBuilder.java:52)
at org.apache.ibatis.session.SqlSessionFactoryBuilder.build(SqlSessionFactoryBuilder.java:36)
at test.Test.<clinit>(Test.java:30)
Caused by: org.apache.ibatis.builder. BuilderException: Error parsing SQL Mapper Configuration. Cause: java.io. IOException: Could not find resource com/helloworld/model/UserMapper.xml
at org.apache.ibatis.builder.xml.XMLConfigBuilder.parseConfiguration(XMLConfigBuilder.java:121)
at org.apache.ibatis.builder.xml.XMLConfigBuilder.parse(XMLConfigBuilder.java:99)
at org.apache.ibatis.session.SqlSessionFactoryBuilder.build(SqlSessionFactoryBuilder.java:50)
… 2 more
Caused by: java.io. IOException: Could not find resource com/helloworld/model/UserMapper.xml
at org.apache.ibatis.io.Resources.getResourceAsStream(Resources.java:114)
at org.apache.ibatis.io.Resources.getResourceAsStream(Resources.java:100)
at org.apache.ibatis.builder.xml.XMLConfigBuilder.mapperElement(XMLConfigBuilder.java:371)
at org.apache.ibatis.builder.xml.XMLConfigBuilder.parseConfiguration(XMLConfigBuilder.java:119)
… 4 more
Exception in thread “main” java.lang.NullPointerException
at test.Test.main(Test.java:41)
The error was: Problem creating SqlSession and reported a null pointer error for the main method. Solution: I was careless and wrote a wrong letter in the <mapper> configuration path of mybatis configuration file
Read More:
- [Solved] Mybatis Error: Could not find resource mybatis-conf.xml
- [Solved] Multithreading uses jsch to obtain a session for connection error: session.connect: java.net.socketexception: connection reset
- Mybatis reports an error (error building sqlsession.) when using annotations without deleting redundant files
- Error:Cannot build artifact xxx:war exploded’ because it is included into a circular dependency
- [Solved] mybatis Error querying database. Cause: java.sql.SQLException: The server time zone value
- [Solved] Tk-Mybatis Error: tk.mybatis.mapper.MapperException:
- Mybatis Error: Cause: org.apache.ibatis.builder.BuilderException: Error creating document instance.
- [Solved] mybatis Error: Cause: org.apache.ibatis.builder.BuilderException: Error creating document instance.
- [Solved] Mybatis.generator error: Failed to execute goal org.mybatis.generator:mybatis-generator-maven-plugin:1.3.2
- Mybatis query error: Exception in thread “main” org.apache.ibatis.exceptions.PersistenceException…
- Mybatis Error: Error instantiating class bakou.entity.Person with invalid types () or value)
- [Solved] Java.lang.IllegalStateException: Type handler was null on parameter mapping for property ‘__frch_it
- [Solved] Mybatis-Plus Error: Invalid bound statement (not found)
- [Solved] mybatis plus Insert Error: mybatis plus Error setting null for parameter #1 with JdbcType OTHER
- How to Solve Mybatis error: invalid bound statement (not found)
- [Solved] nested exception is org.apache.ibatis.builder.BuilderException: Error invoking SqlProvider method
- Mybatis single parameter pass in exception (How to Fix)
- Mybatis Error: The error may exist in xxxxMapper.xml [How to Solve]
- Abstract method and static method of java interface
- [Solved] error: method does not override or implement a method from a supertype