Property ‘sqlSessionFactory‘ or ‘sqlSessionTemplate‘ are required

报错信息: Caused by: java.lang.IllegalArgumentException: Property 'sqlSessionFactory' or 'sqlSessionTemplate' are required

1 导入mybatis-spring-boot-starter-test依赖

<dependency>
    <groupId>org.mybatis.spring.boot</groupId>
    <artifactId>mybatis-spring-boot-starter-test</artifactId>
    <version>1.3.2</version>
    <scope>test</scope>
</dependency>

2 检查pom.xml配置的数据库版本与实际数据库版本是否一致,无用
在这里插入图片描述
3 降低spring-boot-starter-parent版本,删除maven仓库里面的jar包,重新导入

  <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
<!--        <version>2.2.2.RELEASE</version>-->
        <version>2.0.1.RELEASE</version>
        <relativePath/>
    </parent>

4 确认是否存在数据库连接池的包

<dependency>
    <groupId>com.alibaba</groupId>
    <artifactId>druid-spring-boot-starter</artifactId>
    <version>1.1.21</version>
</dependency>

5 是否是本地仓库的jar冲突,删除所有jar包,重新下载
6 查看启动类是否有 @SpringBootApplication(exclude = DataSourceAutoConfiguration.class), 有则删除

  • 19
    点赞
  • 24
    收藏
    觉得还不错? 一键收藏
  • 6
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值