出现蓝色部分的报错,一般有如下几种可能:1.Mapper.xml中映射mapper层写错 2.select标签中id值写错。
如果以上两种都没有错,可能是你将mapper.xml文件放在了src/java包中。但是maven加载机制,只会编译src/main/java中的java类型文件,其他类型不会进行加载。所以xml文件中的内容找不到。
解决:1.把xml文件放在resources中
2.通过配置方式进行加载:(1)在pom.xml (2)项目配置文件添加
1、在pom.xml添加
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
<resources>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.yml</include>
<include>**/*.properties</include>
<include>**/*.xml</include>
</includes>
<filtering>false</filtering>
</resource>
<resource>
<directory>src/main/resources</directory>
<includes> <include>**/*.yml</include>
<include>**/*.properties</include>
<include>**/*.xml</include>
</includes>
<filtering>false</filtering>
</resource>
</resources>
</build>
2、application-dev.yml添加
mybatis-plus:
mapper-locations: classpath:com/atguigu/auth/mapper/xml/*.xml