Path pits encountered when SpringBoot integrates Mybatis

Foreword: The
middle station service has been used in the project of the mall, and the middle station service is used including the data. The data middle station exposes the interface to the outside. We can call the sql in the black box and use it when writing another project. It was SpringBoot + Mybatis, and then I ran into this problem, and it took a long time to figure it out.

Problem Description

When creating the Mybatis project, we will generate a corresponding mapper file for each dao-level interface. When creating this file, package scanning is configured. Package scanning can scan all other mapper files, but it cannot be scanned. My newly added mapper file.

Try to solve one:

After checking, I found that there was a mapper file with the same path and file name, so I changed my package name and file name. Then it still doesn't work, and then compiling still doesn't work.

Attempt to solve two:

After determining the file path and file name, check the mapper file. In fact, if there is a problem with the mapper file, it will only report an error when it is called. It must be scanned when the package is scanned. There has been a problem with the troubleshooting ideas here. However, it was found that the mapping was incorrectly written in the mapper. After the change, the compilation still fails to scan.

Attempt to solve three:

After decompressing the compiled project jar package, it was found that the final compiled file, the mapper file should be in the same folder as the class file, but it was compiled to a different folder, so it was determined that there was a problem with the folder creation because it was under construction. This method is used when the folder is supplier.dao.mapper. The folder created in this way does not have a hierarchical structure. In fact, the name of the folder is "supplier.dao.mapper" instead of a three-level folder (the folder is not a package), which leads to After compiling, the mapper cannot be found, modify the folder, and then the compilation problem is solved.

Guess you like

Origin blog.csdn.net/m0_46897923/article/details/114896394