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); } }

     

     

  • 相关阅读:
    解决小程序sessionid不一致
    小程序实现写入缓存与读取缓存
    小程序登录时如何获取input框中的内容
    js实现截取字符串后几位
    js用正则判断身份证号码
    sublime Text3安装及配置与解决安装插件失败
    jQuery实现全选与全部选
    jQuery实现enter键登录
    常用正则表达式的判断与写法
    js实现正则判断手机号
  • 原文地址:https://www.cnblogs.com/virgosnail/p/10020135.html
Copyright © 2011-2022 走看看