整合Spring6+MyBatis3.5.10出现的bug

大致错误为:

警告: Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'accountServiceImpl': Unsatisfied dependency expressed through field 'accountDao': Error creating bean with name 'accountDao' defined in file [E:\Desktop\sm\target\classes\com\mmg\dao\AccountDao.class]: Unsatisfied dependency expressed through bean property 'sqlSessionFactory': Error creating bean with name 'sqlSessionFactoryBean' defined in class path resource [com/mmg/config/DataSourceConfig.class]: Failed to instantiate [org.mybatis.spring.SqlSessionFactoryBean]: Factory method 'sqlSessionFactoryBean' threw exception with message: org/springframework/core/NestedIOException

整合Spring6+MyBatis3.5.10出现的bug_第1张图片

经过我反复的实验,发现了是Spring整合MyBatis的依赖太低,在我们使用Spring6正式版后,Spring整合MyBatis的依赖版本必须为3.0.0以上!在升级依赖后重新启动项目即可!

  
    
      org.springframework
      spring-context
      6.0.3
    
    
      org.springframework
      spring-jdbc
      6.0.3
    
    
      mysql
      mysql-connector-java
      8.0.30
    
    
      org.mybatis
      mybatis
      3.5.11
    
      
    
      org.mybatis
      mybatis-spring
      3.0.1
    
    
      com.alibaba
      druid
      1.2.13
    
  

你可能感兴趣的:(bug,mybatis,spring)