zoukankan      html  css  js  c++  java
  • Spring boot mybatis : Error creating bean with name 'com.github.pagehelper.autoconfigure.MapperAutoConfiguration': Invocation of init method failed;

    报错截图:

    解决方法:

      只能扫描到自定义的mapper,不能扫描到其他文件。

      @MapperScan("com.streamax.s17.tms.dao.pper.repository")

    1. 继承通用Mapper

      此接口不能同其他Mapper一起,该类不能被当做普通Mapper一样被扫描,否则会出错。

    package com.streamax.s17.tms.dao.mapper.core;
    
    
    import tk.mybatis.mapper.common.BaseMapper;
    import tk.mybatis.mapper.common.MySqlMapper;
    
    /**
     * @author cf
     * @date 2018/11/21
     */
    public interface CoreMapper<T> extends BaseMapper<T>, MySqlMapper<T> {
    }

    2. 自定义Mapper继承CoreMapper

      自定义的 Mapper 通过对应有xml的映射文件

      自定义Mapper.java要特别注意,不能同上面的Mapper定义在同一个包下

    package com.streamax.s17.tms.dao.mapper.repository;
    
    import com.streamax.s17.tms.dao.entity.TokenEntity;
    import com.streamax.s17.tms.dao.mapper.core.CoreMapper;
    
    /**
     * @author cf
     * @date 2018/11/21
     */
    public interface TokenMapper extends CoreMapper<TokenEntity> {
    
        /**
         * 根据 entityId 查询token
         *
         * @param entityId
         */
        TokenEntity selectByEntityId(String entityId);
    
    }

    3. MapperScan

    package com.streamax.s17.tms;
    
    import org.mybatis.spring.annotation.MapperScan;
    import org.springframework.boot.SpringApplication;
    import org.springframework.boot.autoconfigure.SpringBootApplication;
    
    @SpringBootApplication
    // 只扫描自定义mapper所在包,不能扫描到继承通用mapper所在包 @MapperScan(
    "com.streamax.s17.tms.dao.mapper.repository") public class TmsApplication { public static void main(String[] args) { SpringApplication.run(TmsApplication.class, args); } }

     

     

  • 相关阅读:
    1405ST软件测试课的要求补充说明
    软测实验课安排和考试
    Asp.Net 4.0 FormAuthentication 原理
    微信支付-“申请退款”接口遇到curl出错,错误码:58
    前端资源构建-Grunt环境搭建
    微信服务号开发-获取用户位置信息
    微信支付开发-当前页面的URL未注册
    Using Redis to store php session
    nginx performance monitor
    thinkphp nginx php-fpm url rewrite 导致 404 错误
  • 原文地址:https://www.cnblogs.com/virgosnail/p/10020135.html
Copyright © 2011-2022 走看看