
Consider defining a bean of type ‘com.project.springboot.mapper.UserMapper‘ in your configuration.
新建springboot项目启动时出现报错:Consider defining a bean of type ‘com.project.springboot.mapper.UserMapper’ in your configuration.
报错提示没有扫描到UserMapper接口类,查询到是Mapper中的UserMapper接口类没有添加Mapper注解导致 解决方法一: 在接口列上添加@Mapper注解
@Mapper public interface UserMapper {}解决方法二: 在运行主类上添加注解@MapperScan,扫描UserMapper所在包Mapper @MapperScan有两种写法,使用时采用一种
public @interface MapperScan { String[] value() default {}; String[] basePackages() default {}; }value类型:
@MapperScan("com.project.springboot.mapper") public class AppRun { public static void main(String[] args) { SpringApplication.run(AppRun.class, args); } }basePackages类型:
@MapperScan(basePackages = "com.project.springboot.mapper") public class AppRun { public static void main(String[] args) { SpringApplication.run(AppRun.class, args); } }👁️ 阅读量:0
© 版权声明:本文《Consider defining a bean of type ‘com.project.springboot.mapper.UserMapper‘ in your configuration.》内容均为本站精心整理或网友自愿分享,如需转载请注明原文出处:https://www.zastudy.cn/wen/1686554715a290585.html。