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后重新启动,可正常启动。

  • 相关阅读:
    SV——override
    SV——声明和例化
    SV——automatic
    SV——类型转换$cast
    C++——局部变量、全局变量、静态变量与动态对象的性质(转载)
    C++——动态分配内存
    异步复位,同步释放(转)
    异步复位中的recovery time和removal time(转)
    UVM——virtual sequencer和virtual sequence
    软件工程 实践者的研究方法 第38章答案
  • 原文地址:https://www.cnblogs.com/wwmiert/p/9838221.html
Copyright © 2011-2022 走看看