??歡迎來到@邊境矢夢°的csdn博文??
??本文主要梳理本文針對 MyBatis-plus,對于 MyBatis 報相同的錯誤,可以看這個大佬的文章:SpringBoot3整合MyBatis報錯:Property ‘sqlSessionFactory‘ or ‘sqlSessionTemplate‘ are required ??
??我是邊境矢夢°,一個正在為秋招和算法競賽做準備的學生??
??喜歡的朋友可以關(guān)注一下??????,下次更新不迷路??
針對報錯如下:
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 或以上。對應(yīng)如下兩部分代碼:<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>
?部分:文章來源:http://www.zghlxwxcb.cn/news/detail-753353.html
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.7.8</version>
<relativePath/>
</parent>
<dependency>
?部分:文章來源地址http://www.zghlxwxcb.cn/news/detail-753353.html
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>3.5.3</version>
</dependency>
到了這里,關(guān)于【SpringBoot】MyBatis-plus 報錯 Property ‘sqlSessionFactory‘ or ‘sqlSessionTemplate‘ are required的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!