最新消息: USBMI致力于为网友们分享Windows、安卓、IOS等主流手机系统相关的资讯以及评测、同时提供相关教程、应用、软件下载等服务。

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

业界 admin 3浏览 0评论

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!
稍微记录一下!

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!
稍微记录一下!

与本文相关的文章

发布评论

评论列表 (0)

  1. 暂无评论