【SpringBoot】MyBatis-plus 报错 Property ‘sqlSessionFactory‘ or ‘sqlSessionTemplate‘ are required

??欢迎来到@的csdn博文??
??本文主要梳理本文针对 MyBatis-plus,对于 MyBatis 报相同的错误,可以看这个大佬的文章:SpringBoot3整合MyBatis报错:Property ‘sqlSessionFactory‘ or ‘sqlSessionTemplate‘ are required ??
??我是,一个正在为秋招和算法竞赛做准备的学生??
??喜欢的朋友可以关注一下???,下次更新不迷路??

针对报错如下:

Property 'sqlSessionFactory' or 'sqlSessionTemplate' are required
方法1: 就用SpringBoot 3

如果 pom.xml 中spring-boot-starter-parent的版本需要使用 3.0.0 或以上,则mybatis-plus-boot-starter的版本必须为 3.5.3 或以上。对应如下两部分代码:
<parent>部分:

	<parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>3.0.1</version>
        <relativePath/>
    </parent>

<dependency>部分:

        <dependency>
            <groupId>com.baomidou</groupId>
            <artifactId>mybatis-plus-boot-starter</artifactId>
            <version>3.5.3</version>
        </dependency>
方法2:不需要使用SpringBoot 3

如果 pom.xml 中spring-boot-starter-parent的版本不需要使用 3.0.0 或以上,则可以将其版本改为 2.7.8 即 SpringBoot 2 版本,mybatis-plus-boot-starter的版本无需使用最新的 3.5.3(mybatis-plus 在 3.4 和 3.5 版本之间有较大变化,按需使用即可)。
<parent>部分:

	<parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.7.8</version>
        <relativePath/> 
    </parent>

<dependency>部分:

        <dependency>
            <groupId>com.baomidou</groupId>
            <artifactId>mybatis-plus-boot-starter</artifactId>
            <version>3.5.3</version>
        </dependency>