admin管理员组文章数量:1794759
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); } }本文标签: typeprojectdefiningbeanUserMapper
版权声明:本文标题:Consider defining a bean of type ‘com.project.springboot.mapper.UserMapper‘ in your configuration. 内容由林淑君副主任自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.xiehuijuan.com/baike/1686554497a81266.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论