zoukankan      html  css  js  c++  java
  • Consider defining a bean of type 'com.xxx.mapper.XsMapper' in your configuration

    详细描述:

    Field xsMapper in com.xxx.controller.XsController required a bean of type 'com.xxx.mapper.XsMapper' 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.xxx.mapper.XsMapper' in your configuration.

     

    解决:

    这个是没有指定mybatis扫包的范围,sb不知道去哪里装载。

    1)在Application类中指定扫包的范围

    @MapperScan("包"),包:就是你的Mapper Interface所在包

    2)可以直接在类上面加注解

    直接在mapper接口上加@Mapper

    说明:

    如果二个都加行不行?答案:不行。今天突然试了一下,发现二个都加也行。:)自已亲测吧。

    如果找不到:@MapperScan,应该咱办呢?

    那肯定是要加入一个mybatis的

    <dependency>
                 <groupId>org.mybatis.spring.boot</groupId>
                 <artifactId>mybatis-spring-boot-starter</artifactId>
                 <version>1.2.0</version>
            </dependency>

     这样就OK了。二种方案,二选一。

     

     

  • 相关阅读:
    装饰器的进阶
    Django admin组件应用
    AJAX
    Cookie、Session和自定义分页
    Django中ORM介绍和字段及字段参数
    Django 框架
    Django之视图
    Django之路由系统
    Django ORM相关操作
    Django 模板语言
  • 原文地址:https://www.cnblogs.com/jiduoduo/p/14072133.html
Copyright © 2011-2022 走看看