当前位置:   article > 正文

解决SpringBoot+MyBatisPlus 报错Property ‘sqlSessionFactory‘ or ‘sqlSessionTemplate‘ are required_mybaitsplus property 'sqlsessionfactory' or 'sqlse

mybaitsplus property 'sqlsessionfactory' or 'sqlsessiontemplate' are require

 报错原因:SpringBoot 与 MyBatis Plus版本不匹配!

 解决方法:

 把SpringBoot版本改为v3.1.6 同时 MyBatis Plus版本改为3.5.3!

 

1.  打开项目的pom.xml文件。修改springboot的版本号,如下图:

 2. 修改MyBatis Plus及其相关组件的版本号,如图:

3. 附上我的pom.xml代码:

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  3. xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
  4. <modelVersion>4.0.0</modelVersion>
  5. <parent>
  6. <groupId>org.springframework.boot</groupId>
  7. <artifactId>spring-boot-starter-parent</artifactId>
  8. <version>3.1.6</version>
  9. <relativePath/> <!-- lookup parent from repository -->
  10. </parent>
  11. <groupId>com.example</groupId>
  12. <artifactId>smartmine</artifactId>
  13. <version>0.0.1-SNAPSHOT</version>
  14. <name>smartmine</name>
  15. <description>Demo project for Spring Boot</description>
  16. <properties>
  17. <java.version>17</java.version>
  18. </properties>
  19. <dependencies>
  20. <dependency>
  21. <groupId>org.springframework.boot</groupId>
  22. <artifactId>spring-boot-starter-web</artifactId>
  23. </dependency>
  24. <dependency>
  25. <groupId>org.springframework.boot</groupId>
  26. <artifactId>spring-boot-starter-web-services</artifactId>
  27. </dependency>
  28. <dependency>
  29. <groupId>com.mysql</groupId>
  30. <artifactId>mysql-connector-j</artifactId>
  31. <scope>runtime</scope>
  32. </dependency>
  33. <!-- mybatisPlus 核心库 -->
  34. <dependency>
  35. <groupId>com.baomidou</groupId>
  36. <artifactId>mybatis-plus-boot-starter</artifactId>
  37. <version>3.5.3</version>
  38. </dependency>
  39. <dependency>
  40. <groupId>com.baomidou</groupId>
  41. <artifactId>mybatis-plus</artifactId>
  42. <version>3.5.3</version>
  43. </dependency>
  44. <dependency>
  45. <groupId>com.baomidou</groupId>
  46. <artifactId>mybatis-plus-generator</artifactId>
  47. <version>3.3.0</version>
  48. </dependency>
  49. <dependency>
  50. <groupId>org.apache.velocity</groupId>
  51. <artifactId>velocity-engine-core</artifactId>
  52. <version>2.3</version>
  53. </dependency>
  54. <dependency>
  55. <groupId>org.springframework.boot</groupId>
  56. <artifactId>spring-boot-starter-test</artifactId>
  57. <scope>test</scope>
  58. </dependency>
  59. <!-- https://mvnrepository.com/artifact/com.alibaba/fastjson -->
  60. <dependency>
  61. <groupId>com.alibaba</groupId>
  62. <artifactId>fastjson</artifactId>
  63. <version>1.2.59</version>
  64. </dependency>
  65. <dependency>
  66. <groupId>org.projectlombok</groupId>
  67. <artifactId>lombok</artifactId>
  68. <optional>true</optional>
  69. </dependency>
  70. </dependencies>
  71. <build>
  72. <plugins>
  73. <plugin>
  74. <groupId>org.springframework.boot</groupId>
  75. <artifactId>spring-boot-maven-plugin</artifactId>
  76. <configuration>
  77. <excludes>
  78. <exclude>
  79. <groupId>org.projectlombok</groupId>
  80. <artifactId>lombok</artifactId>
  81. </exclude>
  82. </excludes>
  83. </configuration>
  84. </plugin>
  85. </plugins>
  86. <resources>
  87. <resource>
  88. <directory>src/main/java</directory>
  89. <includes>
  90. <include>**/*.yml</include>
  91. <include>**/*.properties</include>
  92. <include>**/*.xml</include>
  93. </includes>
  94. <filtering>false</filtering>
  95. </resource>
  96. <resource>
  97. <directory>src/main/resources</directory>
  98. <includes>
  99. <include>**/*.yml</include>
  100. <include>**/*.properties</include>
  101. <include>**/*.xml</include>
  102. </includes>
  103. <filtering>false</filtering>
  104. </resource>
  105. <resource>
  106. <directory>lib</directory>
  107. <includes>
  108. <include>**/*.jar</include>
  109. </includes>
  110. </resource>
  111. </resources>
  112. </build>
  113. </project>

 

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

闽ICP备14008679号