mybatis版本问题

来源:-

gaidie

2023-09-06 00:06

报错如下:

Description:


A component required a bean of type 'com.xiaogai.allone.mapper.TagMapper' that could not be found.



Action:


Consider defining a bean of type 'com.xiaogai.allone.mapper.TagMapper' in your configuration.


https://img.mukewang.com/64f751a100011afd22670572.jpg


使用的版本为2.2.2的时候,会报上面的错误,使用3.0以后的版本正常


https://img3.mukewang.com/64f751fc000177af18800347.jpg


我的pom文件:


<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
   <modelVersion>4.0.0</modelVersion>
   <parent>
       <groupId>org.springframework.boot</groupId>
       <artifactId>spring-boot-starter-parent</artifactId>
       <version>3.0.10</version>
       <relativePath/> <!-- lookup parent from repository -->
   </parent>
   <groupId>com.xiaogai</groupId>
   <artifactId>allone</artifactId>
   <version>0.0.1-SNAPSHOT</version>
   <name>base-learn-v1</name>
   <description>base-learn-v1</description>
   <properties>
       <java.version>17</java.version>
   </properties>
   <dependencies>
       <dependency>
           <groupId>org.springframework.boot</groupId>
           <artifactId>spring-boot-starter-thymeleaf</artifactId>
       </dependency>
       <dependency>
           <groupId>org.springframework.boot</groupId>
           <artifactId>spring-boot-starter-web</artifactId>
       </dependency>

       <dependency>
           <groupId>org.springframework.boot</groupId>
           <artifactId>spring-boot-starter-test</artifactId>
           <scope>test</scope>
       </dependency>
       <dependency>
           <groupId>org.projectlombok</groupId>
           <artifactId>lombok</artifactId>
           <optional>true</optional>
       </dependency>
       <dependency>
           <groupId>org.mybatis.spring.boot</groupId>
           <artifactId>mybatis-spring-boot-starter</artifactId>
<!--            <version>2.2.2</version>-->
           <version>3.0.2</version>
       </dependency>
       <dependency>
           <groupId>mysql</groupId>
           <artifactId>mysql-connector-java</artifactId>
           <version>8.0.29</version>
       </dependency>
       <dependency>
           <groupId>org.springframework.boot</groupId>
           <artifactId>spring-boot-starter-thymeleaf</artifactId>
       </dependency>
       <dependency>
           <groupId>org.webjars</groupId>
           <artifactId>webjars-locator</artifactId>
           <version>0.45</version>
       </dependency>
       <dependency>
           <groupId>org.webjars</groupId>
           <artifactId>jquery</artifactId>
           <version>3.5.1</version>
       </dependency>
       <dependency>
           <groupId>org.webjars</groupId>
           <artifactId>layui</artifactId>
           <version>2.5.7</version>
       </dependency>
   </dependencies>

   <build>
       <plugins>
           <plugin>
               <groupId>org.springframework.boot</groupId>
               <artifactId>spring-boot-maven-plugin</artifactId>
           </plugin>
       </plugins>
   </build>

</project>


写回答 关注

1回答

  • gaidie
    2023-09-06 00:08:06

    mybatis的版本与Spring Boot应该匹配,不然报如下错误:



    Description:


    A component required a bean of type 'com.xiaogai.allone.mapper.TagMapper' that could not be found.



    Action:


    Consider defining a bean of type 'com.xiaogai.allone.mapper.TagMapper' in your configuration.




    https://img.mukewang.com/64f75254000186d817370347.jpg


Spring Boot3.0最新版入门与商品特征打标实战

Spring Boot3.0最新版入门与商品特征打标实战

3224 学习 · 9 问题

查看课程

相似问题