报错如下:
解决办法:
在配置文件中指定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>