Consider defining a bean of type ‘com.csf.mapper.UserMapper‘ in your configuration

编程知识 更新时间:2023-05-02 05:30:13

SpringBoot整合mybatis时,启动报错:

**Field userMapper in com.csf.controller.UserController required a bean of type ‘com.csf.mapper.UserMapper’ that could not be found.
The injection point has the following annotations:
- @org.springframework.beans.factory.annotation.Autowired(required=true)
Action:
Consider defining a bean of type ‘com.csf.mapper.UserMapper’ in your configuration.
Process finished with exit code 1
**
找不到UserMapper这个接口,具体原因,UserMapper没有被IOC容器扫描到,我的包导入的都是正确的,唯一没有弄好的时springboot启动器上面没有添加注解,具体映射扫描到UserMapper所在的包。

添加@MapperScan()

@SpringBootApplication
@MapperScan("com.csf.mapper")
public class Application {
    public static void main(String[] args) {
        SpringApplication.run(Application.class,args);
    }
}

OK!
稍微记录一下!

更多推荐

Consider defining a bean of type ‘com.csf.mapper.UserMapper‘ in your configurati

本文发布于:2023-04-26 06:41:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/9b70725b2cdb3379f1ef8c914ca5d690.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:type   bean   defining   csf   configuration

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!

  • 104538文章数
  • 26215阅读数
  • 0评论数