Resolución de error mybatis-plus del proyecto SpringBoot 3: org.apache.ibatis.binding.BindingException: declaración enlazada no válida

Encontré un pozo que tardó más de media hora en resolverse y lo registré aquí para evitar que otros encuentren problemas similares.

Fenómeno problemático

SpringBoot 3.1.3, usando la versión mybatis-plus 3.5.1 , se ejecuta e informa un error:

org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): xxxMapper.insert

	at org.apache.ibatis.binding.MapperMethod$SqlCommand.<init>(MapperMethod.java:229)
	at org.apache.ibatis.binding.MapperMethod.<init>(MapperMethod.java:53)
	at org.apache.ibatis.binding.MapperProxy.lambda$cachedInvoker$0(MapperProxy.java:96)
	at java.base/java.util.concurrent.ConcurrentHashMap.computeIfAbsent(ConcurrentHashMap.java:1708)
	at org.apache.ibatis.util.MapUtil.computeIfAbsent(MapUtil.java:36)
	at org.apache.ibatis.binding.MapperProxy.cachedInvoker(MapperProxy.java:94)
	at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:86)
	at jdk.proxy2/jdk.proxy2.$Proxy62.insert(Unknown Source)
	at com.baomidou.mybatisplus.extension.service.IService.save(IService.java:63)
  //...
	at org.junit.platform.launcher.core.SessionPerRequestLauncher.execute(SessionPerRequestLauncher.java:53)
	at com.intellij.junit5.JUnit5IdeaTestRunner.startRunnerWithArgs(JUnit5IdeaTestRunner.java:57)
	at com.intellij.rt.junit.IdeaTestRunner$Repeater$1.execute(IdeaTestRunner.java:38)
	at com.intellij.rt.execution.junit.TestsRepeater.repeat(TestsRepeater.java:11)
	at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:35)
	at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:232)
	at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:55)

Leí muchos artículos y descubrí que eran inútiles, y finalmente encontré el motivo en el problema de Github : ¡mybatis-plus 3.5.3 solo es compatible con Spring Boot 3!

Solución:

Entonces la solución es actualizar la versión mybatis-plus a 3.5.3 o posterior.

La última versión oficial del 16.09.2023 es: 3.5.3.2

<dependency>
    <groupId>com.baomidou</groupId>
    <artifactId>mybatis-plus</artifactId>
    <version>3.5.3.2</version>
</dependency

Actualicé a 3.5.3 localmente y estuvo bien:

        <dependency>
            <groupId>com.baomidou</groupId>
            <artifactId>mybatis-plus-boot-starter</artifactId>
            <version>3.5.3</version>
        </dependency>

Aquí están las otras versiones:

  1. JDK 17
  2. SpringBoot 3.1.3
  3. Mi robot 3.0.2
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>3.1.3</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
        <dependency>
            <groupId>org.mybatis.spring.boot</groupId>
            <artifactId>mybatis-spring-boot-starter-test</artifactId>
            <version>3.0.2</version>
            <scope>test</scope>
        </dependency>

enlaces relacionados

https://github.com/baomidou/mybatis-plus/issues/4997

Supongo que te gusta

Origin blog.csdn.net/u011240877/article/details/132925544
Recomendado
Clasificación