错误信息:


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

    com.baomidou.mybatisplus.core.MybatisXMLScriptBuilder$ForEachHandler.handleNode(MybatisXMLScriptBuilder.java:230)

The following method did not exist:

    org.apache.ibatis.scripting.xmltags.ForEachSqlNode.<init>(Lorg/apache/ibatis/session/Configuration;Lorg/apache/ibatis/scripting/xmltags/SqlNode;Ljava/lang/String;Ljava/lang/Boolean;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V

The method's class, org.apache.ibatis.scripting.xmltags.ForEachSqlNode, is available from the following locations:

    jar:file:/C:/Users/buddy/.m2/repository/org/mybatis/mybatis/3.5.6/mybatis-3.5.6.jar!/org/apache/ibatis/scripting/xmltags/ForEachSqlNode.class

The class hierarchy was loaded from the following locations:

    org.apache.ibatis.scripting.xmltags.ForEachSqlNode: file:/.m2/repository/org/mybatis/mybatis/3.5.6/mybatis-3.5.6.jar


	

pom.xml文件配置

<?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>2.5.0</version>
		<relativePath/> <!-- lookup parent from repository -->
	</parent>
	<groupId>com.example</groupId>
	<artifactId>demo</artifactId>
	<version>0.0.1-SNAPSHOT</version>
	<name>BootBuddy01</name>
	<description>Demo project for Spring Boot</description>
	<properties>
		<java.version>1.8</java.version>
	</properties>
	<dependencies>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-web</artifactId>
		</dependency>
		<dependency>
			<groupId>org.projectlombok</groupId>
			<artifactId>lombok</artifactId>
			<optional>true</optional>
		</dependency>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-test</artifactId>
			<scope>test</scope>
		</dependency>
		<!-- mysql驱动依赖 -->
		<dependency>
			<groupId>mysql</groupId>
			<artifactId>mysql-connector-java</artifactId>
			<version>5.1.47</version>
			<scope>runtime</scope>
		</dependency>
<!--		热部署工具-->
		<dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
            <optional>true</optional>
        </dependency>
<!--		mybatis-->
		<dependency>
            <groupId>org.mybatis.spring.boot</groupId>
            <artifactId>mybatis-spring-boot-starter</artifactId>
            <version>2.1.4</version>
        </dependency>
<!--		mybatis-plus-->
		<dependency>
			<groupId>com.baomidou</groupId>
			<artifactId>mybatis-plus-boot-starter</artifactId>
			<version>3.5.7</version>
		</dependency>
		<dependency>
			<groupId>junit</groupId>
			<artifactId>junit</artifactId>
			<scope>test</scope>
		</dependency>
	</dependencies>
	<build>
		<plugins>
			<plugin>
				<groupId>org.springframework.boot</groupId>
				<artifactId>spring-boot-maven-plugin</artifactId>
				<configuration>
					<excludes>
						<exclude>
							<groupId>org.projectlombok</groupId>
							<artifactId>lombok</artifactId>
						</exclude>
					</excludes>
				</configuration>
			</plugin>
		</plugins>
	</build>

</project>

在写测试的时候发现报错了,一开始想的是Mybatis-plus是mybatis的增强工具,应该是两个都是需要引入的,百度了一番,后面发现有可能是是版本兼容的问题,对比了一下网上的例子发现别人的代码没有引入mybatis依赖,我删除了pom.xml的mybatis依赖,后面发现正常了。又踩了一个新手坑👍👍👍

总结:

依赖关系

MyBatis-Plus 是基于 MyBatis 的增强工具,它在 MyBatis 的基础上提供了更多的功能和便利性。因此,MyBatis-Plus 依赖于 MyBatis,当你在 pom.xml 中引入 MyBatis-Plus 时,它会自动引入 MyBatis 的核心依赖。

依赖传递

在 Maven 项目中,依赖是可以传递的。当你引入一个依赖时,它所依赖的其他库也会被自动引入。因此,当你在 pom.xml 中引入 MyBatis-Plus 时,MyBatis 的核心库也会被自动引入,不需要你手动再引入 MyBatis。

Logo

魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。

更多推荐