当前位置:   article > 正文

启动SpringBoot报错:Property ‘sqlSessionFactory‘ or ‘sqlSessionTemplate‘ are required_unsatisfied dependency expressed through field 'us

unsatisfied dependency expressed through field 'usermapper': error creating

springboot 项目启动时报如下错误

在这里插入图片描述

[AbstractApplicationContext.java:592] → [Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'loginController': Unsatisfied dependency expressed through field 'userService': Error creating bean with name 'userServiceImpl': Unsatisfied dependency expressed through field 'userMapper': Error creating bean with name 'userMapper' defined in file [D:\projects\tutorails_kanomoku\practisesvr\target\classes\com\zhangziwa\practisesvr\mapper\UserMapper.class]: Property 'sqlSessionFactory' or 'sqlSessionTemplate' are required]

原因 版本不兼容

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>3.0.5</version>
    <relativePath/> <!-- lookup parent from repository -->
</parent>

<dependency>
    <groupId>org.mybatis.spring.boot</groupId>
    <artifactId>mybatis-spring-boot-starter</artifactId>
    <version>2.1.0</version>
</dependency>
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12

方案:升级 mybatis-spring-boot-starter 版本即可

<dependency>
    <groupId>org.mybatis.spring.boot</groupId>
    <artifactId>mybatis-spring-boot-starter</artifactId>
    <version>3.0.2</version>
</dependency>
  • 1
  • 2
  • 3
  • 4
  • 5

在这里插入图片描述

参考

SpringBoot3整合MyBatis报错:Property ‘sqlSessionFactory‘ or ‘sqlSessionTemplate‘ are required

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/繁依Fanyi0/article/detail/662283
推荐阅读
相关标签
  

闽ICP备14008679号