mybatis-plus @Select注解的坑 The method‘s class, org.apache.ibatis.annotations.Select, is available from

运行报错信息如下:

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
[threathunting:172.20.1.102:28085] 2022-11-04 15:02:23.912 ERROR 20660 [-] [main] o.s.b.d.LoggingFailureAnalysisReporter   

***************************
APPLICATION FAILED TO START
***************************

Description:

An attempt was made to call a method that does not exist. The attempt was made from the following location:

    com.baomidou.mybatisplus.core.MybatisMapperAnnotationBuilder$AnnotationWrapper.<init>(MybatisMapperAnnotationBuilder.java:677)

The following method did not exist:

    org.apache.ibatis.annotations.Select.databaseId()Ljava/lang/String;

The method's class, org.apache.ibatis.annotations.Select, is available from the following locations:

    jar:file:/D:/repository/org/mybatis/mybatis/3.5.3/mybatis-3.5.3.jar!/org/apache/ibatis/annotations/Select.class

The class hierarchy was loaded from the following locations:

    org.apache.ibatis.annotations.Select: file:/D:/repository/org/mybatis/mybatis/3.5.3/mybatis-3.5.3.jar


Action:

Correct the classpath of your application so that it contains a single, compatible version of org.apache.ibatis.annotations.Select

Disconnected from the target VM, address: '127.0.0.1:59677', transport: 'socket'

Process finished with exit code 1

 问题分析,发现引用的是 mybatis 下的 select 包

 在我的 maven pom.xml 中没有找到这个包

使出必杀技,在 idea terminal 窗口执行

mvn dependency:tree > a.txt

在项目目录会生成该工程的所有的maven依赖包

 在 pagehelper 分页插件中引入了 mybatis jar 包

接下来问题就很好解决了,在项目中找到pagehelper 这个依赖,包 mybatis 依赖排除

        <!--pagehelper-->
        <dependency>
            <groupId>com.github.pagehelper</groupId>
            <artifactId>pagehelper-spring-boot-starter</artifactId>
            <version>1.2.13</version>
            <exclusions>
                <exclusion>
                    <artifactId>mybatis</artifactId>
                    <groupId>org.mybatis</groupId>
                </exclusion>
            </exclusions>
        </dependency>

 操作完上述操作,从新启动项目,启动成功

猜你喜欢

转载自blog.csdn.net/wangguoqing_it/article/details/127689261