zoukankan      html  css  js  c++  java
  • springboot整合mybatis遇到无法扫描MaperScan包的问题

    1.启动类加上@MaperScan注解后,一直报错如下:

    Error creating bean with name 'platUserMapper' defined in file [D:workspaceeclipse_datavivo argetclasses estinterfdomainmapperPlatUserMapper.class]: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Property 'sqlSessionFactory' or 'sqlSessionTemplate' are required

    原因是pom.xml没有引入如下依赖,因为从SqlSessionDaoSupport 这个类的源码中可以看出,原因是mybatis-spring-1.2.0中取消了自动注入SqlSessionFactory 和 SqlSessionTemplate

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

    2.引入如上依赖包后,再次报错,报错如下:

    Failed to instantiate [org.apache.ibatis.session.SqlSessionFactory]: Factory method 'sqlSessionFactory' threw exception; nested exception is java.lang.NoSuchMethodError: org.apache.ibatis.session.Configuration.setVfsImpl(Ljava/lang/Class;)V

    查看源码发现该类中不存在set方法 ,升级mybatis版本如下:

    <dependency>
    <groupId>org.mybatis</groupId>
    <artifactId>mybatis</artifactId>
    <version>3.4.4</version>
    </dependency>

    仍然报错:Failed to instantiate [org.apache.ibatis.session.SqlSessionFactory]: Factory method 'sqlSessionFactory' threw exception; nested exception is java.lang.NoSuchMethodError: org.mybatis.spring.SqlSessionFactoryBean.setVfs(Ljava/lang/Class;)V

    升级mybatis-spring:

    <dependency>
    <groupId>org.mybatis</groupId>
    <artifactId>mybatis-spring</artifactId>
    <version>1.3.1</version>
    </dependency>

    更新pom后重新启动,可正常启动。

  • 相关阅读:
    javascript之数组去重方法
    经典问题之爬楼梯
    javascript之事件循环机制
    javascript之闭包
    javascript之动态改变this上下文
    块级元素的垂直居中对齐
    js数组对象
    javascript-冒泡法排序
    javascript-数组
    javascript-循环
  • 原文地址:https://www.cnblogs.com/wwmiert/p/9838221.html
Copyright © 2011-2022 走看看