springboot中无法加载dao同级目录下.xml文件
(1)在pom.xml文件下添加如下配置
<resource> <directory>${basedir}/src/main/java</directory> <includes> <include>**/**</include> </includes> </resource>
(2)在.yml或者.properties文件下添加类似如下配置
mybatis.mapper-locations=com/example/demomybatis/dao/mapping/*.xml mybatis.type-aliases-package=com.example.demomybatis.entity
(2.1)以上配置若不对,参考如下配置
application.yml的配置
mybatis: config-location:classpath:mybatis/mybatis.cfg.xml # mybatis配置文件所在路径 mapper-locations:classpath*:com/example/demo/**/dao/xml/*.xml # mapper映射文件
**
一定要注意classpath*
application.properties的配置
**
#mybatis的mapper配置文件 # mybatis配置文件所在路径 mybatis.config-location:classpath:mybatis-config.xml # 所有的mapper映射文件 mybatis.mapper-locations:classpath*:com/springboot/mapper/*.xml
(3)在springboot启动类下添加如下注解
@MapperScan("com.example.demomybatis.dao")
参考连接:https://blog.csdn.net/something0224/article/details/83656917