Create a maven interface in the project, write the sql statement in the xml file, and an error occurs in the execution
org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.atzexu.eduservice.mapper.EduCourseMapper.getPublishCourseInfo
The xml file is in the java directory
reason
This error is caused by maven's default loading mechanism
When maven loads, compile the .java type files in the java folder, and other types of files will not be loaded
solve
method one:
Copy the xml directly to the target file directory (this method is not used much)
Method Two:
Put xml directly in the resource directory (the directory structure is automatically generated by code, this method will change the file structure)
Method three:
Realized by configuration
(1)pom.xml
<!-- Let maven load the xml file in the main.java directory --> <build> <resources> <resource> <directory>src/main/java</directory> <!-- What type of file to load -- > <includes> <include>**/*.xml</include> </includes> <filtering>false</filtering> </resource> </resources> </build>
(2) project application.properties
Set the path where the xml file is located
# Configure the path of the mapper xml file mybatis-plus.mapper-locations=classpath:com/xxx/eduservice/mapper/xml/*.xml
Note: Both pom and properties need to be configured