Mybatis plus reports an error: invalid bound statement (not found)
After integrating mybatis plus in the spring boot project, it is found that the user-defined query method will report an error: “invalid bound statement (not found): * * *.” your method “, which means that your user-defined method cannot be found in the XML file. Various methods are tried and the problem is finally solved. This problem exists in the following situations:
1. Mapper file and XML file cannot correspond
1. Check whether mapper file and XML file names are consistent
UserMapper and UserMapper.xml
2. Check whether the attribute configuration of namespace in the XML file corresponds to the corresponding mapper file
<mapper namespace="com.*.*.mapper.UserMapper">
3. Check whether the method binding ID in the XML file is consistent
Mapper:
List<User> getUserList();
xml:
<select id="getUserList" resultType="com.*.*.entity.User">
SELECT * FROM user
</select>
2. The XML file is placed in the resources directory at different levels and is not packaged into the target
By default, all will be packaged. Check whether the property of not packaging is configured in the POM file, and modify it
Note: this configuration is to package the resources directory and check the differences
<build>
<!-- Pack the files in the resources directory -->
<resources>
<resource>
<directory>src/main/resources</directory>
<includes>
<include>**/*.*</include>
</includes>
</resource>
</resources>
</build>
(focus on configuration, which is also my problem) third, the XML file is placed in the resources directory at different levels and has been packaged into the target, but the corresponding method cannot be found
It is thought that after packaging, you can match according to the name. Finally, it is found that even if the XML file is packaged, it still belongs to a different level from mapper, so check whether the mybatis plus configuration matching the location of the XML file is missing
mybatis-plus.mapper-locations = classpath:mapping/*.xml
# The "mapping" in this configuration corresponds to the name of the directory where your xml is located
Read More:
- How to Solve Mybatis error: invalid bound statement (not found)
- Mybatis Error: Invalid bound statement (not found)
- Springboot mybatis Integrate Error: Invalid bound statement (not found): com…DepartmentMapper.save
- [How to Solve] Invalid bound statement (not found)
- How to Solve Error: Invalid bound statement (not found)
- There was an unexpected error (type=Internal Server Error, status=500).Invalid bound statement (not
- [Solved] Mybatis Batch Modify Error: multi-statement not allow
- [Solved] Mybatis Error: Could not find resource mybatis-conf.xml
- Mybatis plus configuration console prints complete SQL statement with parameters
- Using mybatis statement.getGenreatedKeys(); usegeneratedkeys = “true”; using self incrementing primary key to get primary key value policy and Oracle do not support self incrementing, Oracle uses sequence
- [Solved] Mybatis.generator error: Failed to execute goal org.mybatis.generator:mybatis-generator-maven-plugin:1.3.2
- Mybatis sets the primary key Auto-Increment error: No setter found for the keyProperty
- [Solved] Tk-Mybatis Error: tk.mybatis.mapper.MapperException:
- Mybatis Error: Error instantiating class bakou.entity.Person with invalid types () or value)
- Ternary operator in Java?: error: not a statement
- [Solved] mybatis plus Insert Error: mybatis plus Error setting null for parameter #1 with JdbcType OTHER
- [Solved] Could not find resource COM / atguigu / Dao / studentdao.xm, the mapper file for storing SQL statements could not be found and an error occurred
- HQL statement query error: could not resolve property [Solved]
- Build a mybatis and it will appear session.selectOne Method error
- Mybatis query error: Exception in thread “main” org.apache.ibatis.exceptions.PersistenceException…