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

SpringBoot整合mybatis时,启动报错: **Field userMapper in com.csf.controller.UserController required a bea

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

发布者:admin,转转请注明出处:http://www.yc00.com/web/1738336582a4038975.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信