MybatisPlus报错:BindingException: Invalid bound statement (not found): com...XxxMapper.insert

Mybatis-plus binding error prompts the solution of BindingException: Invalid bound statement

    The general reason is that the definition of the Mapper interface and the xml file do not correspond, and it is necessary to check whether the package name, namespace, function name, etc. can correspond.
    If the above steps are checked, the pom.xml file will be checked abnormally

The general reason is that the definition of the Mapper interface and the xml file do not correspond, and it is necessary to check whether the package name, namespace, function name, etc. can correspond.

Follow the steps below to execute one by one:
1. Check whether the package name of the xml file is in one-to-one correspondence with the package name corresponding to the interface

2. Check whether the namespace of the xml file corresponds to the package name of the xml file one by one

3. Check whether the function name can correspond to

4. Remove the Chinese comments in the xml file

5. Feel free to add a space or blank line in the xml file and save it.
If the above steps are checked, the pom.xml file will be checked abnormally.

Check if the following content has been added

Note: When developing with IDEA, if *Mapper.xml is not automatically copied to the mapper class package in the class output directory when packaging, you need to add the configuration of mybatis loading configuration file in the pom file!

    <build>
        <resources>
            <resource>
                <directory>src/main/java</directory>
                <includes>
                    <include>**/*Mapper.xml</include>
                </includes>
            </resource>
            <resource>
                <directory>src/main/resources</directory>
                <includes>
                    <include>**</include>
                </includes>
            </resource>
        </resources>
    </build>

This is because the following code has been added to application.yml (modified according to your own path):

mybatis-plus.mapper-locations=classpath:/com/example/computer/mapper/*Mapper.xml

At the same time, your xxxMapper file needs to add @Mapper and @Repository.

Under your xxxApplication startup class, add:

@MapperScan("com.example.computer.mapper")

Note: The path in parentheses is your mapper path.

Guess you like

Origin blog.csdn.net/qq_34412985/article/details/127747690