idea 中maven的SpringBoot工程 如果扫包 都好着 但是运行找不到mapper文件中的方法???
Invalid bound statement (not found)
项目中创建mapper接口,编写xml文件sql语句,执行出错
- 解决
- 这个问题是maven的加载机制造成的
maven加载的时候,默认只加载java类型的文件,xml文件不会进行加载
- 复制xml文件进target中;
- 把xml文件放到resource中
- 推荐使用:
a. 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>**/*.properties</include>
<include>**/*.xml</include>
<include>**/*.yml</include>
</includes>
<filtering>false</filtering>
</resource>
<resource>
<directory>src/main/resources</directory>
<includes>
<include>**/*.properties</include>
<include>**/*.xml</include>
<include>**/*.yml</include>
</includes>
<filtering>false</filtering>
</resource>
</resources>
</build>
b. 项目application.properties
mybatis-plus:
configuration:
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
mapper-locations: classpath:com/tjk/eduservice/mapper/xml/*.xml
c. 需要将maven进行重新加载 问题即可解决