Mapped Statements collection does not contain value for XXXX

Today, I stepped into an interesting pit with mybatis. After a day’s searching, I didn’t find the problem. Let me tell you about the conventional solutions.

The command space of the mapping file of

    mybatis is inconsistent with the fully qualified name of the interface; it is possible that the name of the mapping file of mybatis is inconsistent with the class name of the interface; in another case, the method declared by the interface is not included in the mapping file.

But I checked n times! N times! There is no problem. It’s perfect, but it’s a mistake!

The result is that the XML file is not compiled!

When compiling, put the XML file in the folder like this

you can see that the XML file is not compiled.
We are here pom.xml Add the following code to the

<build>
        <resources>
            <resource>
                <directory>src/main/java</directory>
                <includes>
                    <include>**/*.xml</include>
                </includes>
            </resource>
            <resource>
                <directory>${basedir}/src/main/resources</directory>
            </resource>
        </resources>
    </build>

Recompile

XML is compiled to solve the problem


Read More: