No qualifying bean of type ‘com.tengyun.itinerary.mapper.ClasMapper’ available: expected at least 1 bean which qualifies as autow
没有合格的bean可用,没有扫描到mapper,需要在启动类中加入,@MapperScan(" com.test.test1.mapper ")

Invalid bound statement (not found): com.tengyun.itinerary.service.ClasService.pageClas
绑定语句无效,没有加载到mapper.xml文件,如果你的mapper.xml放在Java类文件夹中,需要在pom.xml中配置,放在dependencies标签外
<!-- 项目打包时会将java目录中的*.xml文件也进行打包,**多级目录 -->
<build>
<resources>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.xml</include>
</includes>
<filtering>false</filtering>
</resource>
</resources>
</build>
在application.properties配置文件中,配置
#配置mapper xml文件的路径
mybatis-plus.mapper-locations=classpath:com/lsl/eduservice/mapper/xml/*.xml
yml格式
mybatis-puls:
mapper-locations: classpath:/com/tengyun/itinerary/mapper/xml/*.xml
不要把路径写错了
本文主要探讨了Spring Boot应用中遇到的Mapper扫描问题。当出现'No qualifying bean of type ‘com.tengyun.itinerary.mapper.ClasMapper’ available'错误时,解决方案是在启动类上添加@MapperScan注解指定mapper包路径。同时,如果出现'Invalid bound statement (not found)',可能是因为mapper.xml文件未被正确加载,需检查文件位置并在pom.xml中配置资源包含,或者在application.properties/yml中设置mapper的路径。确保路径正确无误,避免启动失败。
396

被折叠的 条评论
为什么被折叠?



