Property ‘sqlSessionFactory‘ or ‘sqlSessionTemplate‘ are required

这篇具有很好参考价值的文章主要介绍了Property ‘sqlSessionFactory‘ or ‘sqlSessionTemplate‘ are required。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

项目场景:

最近因为公司业务需要在搭一个新架构,用的springboot3和jdk17,在整合mybatis多数据源的时候报错
(引用的mybatisplus 和 mybatisplusjion的是最新的包-2023-08-26)
Error creating bean with name ‘XXXServiceImpl’: Unsatisfied dependency expressed through field ‘baseMapper’: Error creating bean with name ‘XXXMapper’ defined in file [XXXXMapper.class]: Property ‘sqlSessionFactory’ or ‘sqlSessionTemplate’ are required


问题描述

各模块引入的相关jar包

            <dependency>
                <groupId>com.baomidou</groupId>
                <artifactId>dynamic-datasource-spring-boot-starter</artifactId>
                <version>4.1.3</version>
            </dependency>
        <!--mybatis-->
        <dependency>
            <groupId>com.baomidou</groupId>
            <artifactId>mybatis-plus-annotation</artifactId>
             <version>3.5.3.2</version>
        </dependency>
        <dependency>
             <groupId>org.postgresql</groupId>
             <artifactId>postgresql</artifactId>
             <version>42.3.3</version>
        </dependency>        
        <dependency>
            <groupId>com.baomidou</groupId>
            <artifactId>mybatis-plus-extension</artifactId>
             <version>3.5.3.2</version>
        </dependency>            
        <dependency>
            <groupId>com.github.yulichang</groupId>
            <artifactId>mybatis-plus-join-boot-starter</artifactId>
            <type>pom</type>
            <version>1.4.6</version>
        </dependency>
        <dependency>
            <groupId>com.baomidou</groupId>
            <artifactId>mybatis-plus-boot-starter</artifactId>
            <version>3.5.3.2</version>
        </dependency>

1、首先我想到的是不是mapper和service没有扫描到(网上基本都是说这个原因)
Property ‘sqlSessionFactory‘ or ‘sqlSessionTemplate‘ are required,java,开发语言
结果:不是这个原因

2.是不是版本冲突导致自动注入数据源失败

下载依赖冲突扫描工具对各个模块进行扫描
Property ‘sqlSessionFactory‘ or ‘sqlSessionTemplate‘ are required,java,开发语言
Property ‘sqlSessionFactory‘ or ‘sqlSessionTemplate‘ are required,java,开发语言
Property ‘sqlSessionFactory‘ or ‘sqlSessionTemplate‘ are required,java,开发语言
结果:不是这个原因

3.这时候我想到了是不是我都引入的多数据源jar包有问题–dynamic

放弃了这个想法 之前的项目都是用的这个jar包

4.开始各种百度

https://blog.csdn.net/ZHENFENGSHISAN/article/details/128010240
上问说是mybatis-spring-boot-starter的版本问题 我已经引入了mybatisplus最新版本 所有不是这个问题

有文说启动类问题
https://blog.csdn.net/hsuehgw/article/details/129090720
Property ‘sqlSessionFactory‘ or ‘sqlSessionTemplate‘ are required,java,开发语言
我尝试了下 不行
因为我是多数据源 又有文章说 把启动类 调整为 @SpringBootApplication 在yml去排除
Property ‘sqlSessionFactory‘ or ‘sqlSessionTemplate‘ are required,java,开发语言
继续尝试不行

**5.到这里我完全肯定就是jar包问题

sqlSessionFactory为空,我的mybatisplus相关jar包没问题 都是工具官方文档来的 很大可能是dynamic的包
之前没有怀疑是因为直接从其他项目负cv来的

那就开始排查这jar包和jdk版本和springboot版本有没有冲突

     <dependency>
          <groupId>com.baomidou</groupId>
          <artifactId>dynamic-datasource-spring-boot-starter</artifactId>
          <version>4.1.3</version>
    </dependency>

dynamic文档
https://www.kancloud.cn/tracy5546/dynamic-datasource/2264611
Property ‘sqlSessionFactory‘ or ‘sqlSessionTemplate‘ are required,java,开发语言
额 dynamic-datasource 官方 直接把 springboot3 依赖的jar包给变了
调整依赖解决文章来源地址https://www.toymoban.com/news/detail-680067.html

到了这里,关于Property ‘sqlSessionFactory‘ or ‘sqlSessionTemplate‘ are required的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • Java IllegalArgumentException: Property ‘sqlSessionFactory‘ or ‘sqlSessionTemplate‘ are required问题解决

    java.lang.IllegalArgumentException: Property \\\'sqlSessionFactory\\\' or \\\'sqlSessionTemplate\\\' are required 1、一个项目有多个启动模块,一个核心模块,启动模块引用核心模块的代码,只有一个启动模块支持多数据源,其余启动模块还是单数据源,所以不支持多数据源的启动模块引用核心模块时加了

    2024年02月03日
    浏览(27)
  • SpringBoot3整合MyBatis报错:Property ‘sqlSessionFactory‘ or ‘sqlSessionTemplate‘ are required

    遇到了一个 Spring Boot 3 整合 MyBatis 的问题,然后解决了。当然,这其实不是个大问题,只是自己编码时遇到了,然后总结总结分享一下。如果有遇到类似问题的,可以参考一下。 最近在熟悉 Spring Boot 3 版本的代码,开发过程中遇到了一些小坑,不过很快都解决了。然后就用

    2023年04月08日
    浏览(107)
  • 【SpringBoot】MyBatis-plus 报错 Property ‘sqlSessionFactory‘ or ‘sqlSessionTemplate‘ are required

    🎄欢迎来到@边境矢梦°的csdn博文🎄 🎄本文主要梳理本文针对 MyBatis-plus,对于 MyBatis 报相同的错误,可以看这个大佬的文章:SpringBoot3整合MyBatis报错:Property ‘sqlSessionFactory‘ or ‘sqlSessionTemplate‘ are required 🎄 🌈我是边境矢梦°,一个正在为秋招和算法竞赛做准备的学生🌈

    2024年02月05日
    浏览(38)
  • 解决 MyBatis-plus : Property ‘sqlSessionFactory‘ or ‘sqlSessionTemplate‘ are required的问题

    在将MyBatis-plus整合进Springboot项目时,启动后发生 MyBatis-plus : Property ‘sqlSessionFactory‘ or ‘sqlSessionTemplate‘ are required 错误。 这种一般是版本问题,一开始想去官网上查,但发现官网登不上去,之后在gitee上的MyBatis-plus主页查找到了最新的版本,将依赖的版本改一下就行:

    2024年02月10日
    浏览(27)
  • 【Vue】Cannot set reactive property on undefined,null,or primitive value:undefined

    技术栈:vue + element 报错内容: Cannot set reactive property on undefined, null, or primitive value:undefined 如下图所示: 根据报错内容翻译一下,就是不能对 undefined,null 或者原始值为 undefined 的属性设置值。大白话就是不能对字段为 undefined,null 进行赋值,vue 是双向数据绑定。 总的来说,我

    2024年01月18日
    浏览(42)
  • ES删除索引问题 【Wildcard expressions or all indices are not allowed】

    ES 执行操作 DELETE /dmtv_20230415* 出现一下问题 问题解决: Elasticsearch文档说: 删除索引 API 也可以应用于多个索引,方法是使用逗号分隔列表,或者使用 _all 或 *as 索引应用于所有索引(小心!)。 为了禁用允许通过通配符或 _all 删除索引,请将配置中的 action.destructive_require

    2024年02月05日
    浏览(31)
  • No appropriate protocol (protocol is disabled or cipher suites are inappropriate)

    记一次问题: 报错: javax.net.ssl.SSLHandshakeException: No appropriate protocol (protocol is disabled or cipher suites are inappropriate) 这个问题是在我进行接口对接的时候产生的,我方没有对服务jdk版本进行过调整,对接的那一方也进行了沟通,也没有对进口进行过修改,就很奇怪了,算了,既然

    2024年02月17日
    浏览(28)
  • No appropriate protocol (protocol is disabled or cipher suites are inappropriate)(Java版)

    在访问MySQL时出现了,如下错误: 从这里就可以看出MySQL和客户端连接使用的tls版本,可能是TLSv1或者是TLSv1.1,需要放开jdk对TLSv1或者是TLSv1.1黑名单的限制。随便去掉一个TLSv1或者是TLSv1.1即可重现链接。 查询JDK对TLS版本的黑名单限制: vim /Library/Java/JavaVirtualMachines/jdk1.8.0_311

    2023年04月24日
    浏览(24)
  • ERROR: Can‘t find a suitable configuration file in this directory or anyparent. Are you in the right

      解决: 方法一: 检查当前目录: 确保你在配置文件所在的正确目录中。你可以使用命令 \\\"pwd\\\" 来检查当前目录。 检查父目录: 如果配置文件不在当前目录中,可以使用命令 \\\"cd ..\\\" 一级一级地向上移动,直到找到包含配置文件的目录。 搜索配置文件: 如果你仍然找不到配

    2024年02月12日
    浏览(32)
  • unity error CS0246: The type or namespace name ‘xxx‘ could not be found (are you missing a using

    unity 导入了Bitmap使用后报错: error CS0246: The type or namespace name ‘XXX’ could not be found (are you missing a using directive or an assembly reference?) 解决方案如下: .NET Standard 2.1与 .NET Foundation 发布的 .NET Standard 2.1 配置文件匹配。 Unity 建议新项目使用 .NET Standard 2.1。 它比 .NET 4.x 小,有利于尺

    2024年04月26日
    浏览(29)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包