在使用mybatis 不能使用 @select注解的坑,程序运行就会显示找不到类啥的,就像下面的报错信息,这个是存在多个不同版本的包导致的
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:/apache-maven-3.6.3/repository/org/mybatis/mybatis/3.5.1/mybatis-3.5.1.jar!/org/apache/ibatis/annotations/Select.class
It was loaded from the following location:
file:/D:/apache-maven-3.6.3/repository/org/mybatis/mybatis/3.5.1/mybatis-3.5.1.jar
Action:
Correct the classpath of your application so that it contains a single, compatible version of org.apache.ibatis.annotations.Select
- 检查是否包含了多个mybatis的jar包,如果存在去掉其中一个就可以了
2.是否集合其他组件包含了mybatis,例如 activiti包等等,把包含的jar包进行排除即可
<dependency>
<groupId>org.activiti</groupId>
<artifactId>activiti-engine</artifactId>
<version>7.1.0.M6</version>
<exclusions>
<exclusion>
<artifactId>mybatis</artifactId>
<groupId>org.mybatis</groupId>
</exclusion>
<exclusion>
<artifactId>mybatis-plus-extension</artifactId>
<groupId>com.baomidou</groupId>
</exclusion>
<exclusion>
<artifactId>mybatis-plus</artifactId>
<groupId>com.baomidou</groupId>
</exclusion>
</exclusions>
</dependency>
- idea工具可以使用maven helper插件,在pom.xml文件下打开Dependency Analyzer视图就可以清晰的查看哪些包冲突了,不需要的可以直接右键Exclude进行排除jar包
版权声明:本文为qq_41399941原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。