报错:org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.itheima.dao.JobMapper.selectJobAll(找不到mapper.xml)

发布时间 2023-11-22 09:32:39作者: 周文豪

报错如下:

 解决办法:

在配置文件中指定mapper.xml的位置:

mybatis.mapperLocations = classpath*:com/itheima/dao/mappers/*Mapper.xml,com/itheima/dao/secondMappers/*Mapper.xml,com/itheima/dao/*/*/*Mapper.xml

注意:由于上面指定的是Mapper.xml,所以xml文件不要写成Dao.xml。

在pom.xml中添加配置

<properties>

<!-- MyBatis Generator -->
<!-- Java接口和实体类 -->
<targetJavaProject>${basedir}/src/main/java</targetJavaProject>
<targetMapperPackage>com.itheima.dao</targetMapperPackage>
<targetModelPackage>com.itheima.entity</targetModelPackage>
</properties>

<build> <plugins> <resources> <resource> <directory>src/main/resources</directory> <filtering>true</filtering> </resource> <resource> <directory>src/main/webapp</directory> <filtering>false</filtering> </resource> <resource> <directory>src/main/java</directory> <includes> <include>**/*Mapper.xml</include> </includes> <filtering>false</filtering> </resource> </resources> </build>