baomidou / mybatis-plus

An powerful enhanced toolkit of MyBatis for simplify development
https://baomidou.com
Apache License 2.0
16.25k stars 4.29k forks source link

springboot3.3使用jrebel会遇到一个MybatisConfiguration$StrictMap$Ambiguity异常 #6266

Closed kiddkyd2 closed 2 months ago

kiddkyd2 commented 2 months ago

当前使用版本

plugins {
    id 'org.springframework.boot' version '3.3.0'
    id 'io.spring.dependency-management' version '1.1.5'
    id 'org.graalvm.buildtools.native' version '0.10.2'
    id 'java'
}

allprojects {
    apply plugin: 'java'
    group = 'com.os'
    sourceCompatibility = '17'
    targetCompatibility = '17'
    java {
        toolchain {
            languageVersion = JavaLanguageVersion.of(17)
        }
    }

    tasks.whenTaskAdded { task ->
        if (task.name == "lint") {
            task.enabled = false
        }
    }

    gradle.projectsEvaluated {
        tasks.withType(JavaCompile) {
            options.compilerArgs << "-Xlint:none" << "-nowarn"
        }
    }

    // 指定编码格式
    [compileJava, compileTestJava, javadoc]*.options*.encoding = 'UTF-8'

    repositories {
        maven { url 'https://maven.aliyun.com/repository/central' }
        maven { url 'https://maven.aliyun.com/repository/public' }
        maven { url 'https://maven.aliyun.com/repository/jcentral' }
        maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' }
        mavenCentral()
        google()

    }

// 将依赖包复制到lib目录
    task copyJar(type: Copy) {
        // 清除现有的lib目录
        delete "$buildDir\\libs\\lib"
        from configurations.compileClasspath
        into "$buildDir\\libs\\lib"
    }
    configurations {
        all*.exclude group: 'commons-logging', module: 'commons-logging'
    }
}

version = '0.0.1-SNAPSHOT'

subprojects {
    apply plugin: 'org.springframework.boot'
    apply plugin: 'io.spring.dependency-management'

    dependencies {
        implementation('org.springframework.boot:spring-boot-starter')
        implementation('org.springframework.boot:spring-boot-configuration-processor')
        implementation('org.springframework.boot:spring-boot-starter-web')

        implementation('com.mysql:mysql-connector-j')

        implementation('com.baomidou:mybatis-plus-spring-boot3-starter')
        implementation('com.baomidou:dynamic-datasource-spring-boot3-starter')

    }

    dependencyManagement {
        dependencies {
            dependency('com.mysql:mysql-connector-j:8.4.0')
            dependency('com.baomidou:mybatis-plus-spring-boot3-starter:3.5.7')
            dependency('com.baomidou:dynamic-datasource-spring-boot3-starter:4.3.1')
        }
    }

    test {
        useJUnitPlatform()
    }

}

当前环境信息 win11 + springboot3.3.0 + jdk 17 + mysql 5.7.25 + jrebel 2024.2.2 + jrebel mybatisPlus extension 0.0.6

描述bug现象 用jrebel启动后,出现异常: 'com.baomidou.mybatisplus.core.MybatisConfiguration$StrictMap'等异常,但是不影响热更新,项目也能正常使用。

如果不用jrebel启动,而是传统方式启动,就不会有这个异常。据说(百度搜索)这个异常在3.4.*的时候 已经修复?

提供问题复现步骤 1。全新的项目,创建一个子模块os-starter,作为启动类 2。在jrebel里勾选好os-starter需要热更新 3。通过jrebel启动项目

提供完整堆栈日志(可选) 2024-06-19 10:12:01 JRebel: ERROR Class 'com.baomidou.mybatisplus.core.MybatisConfiguration$StrictMap' could not be processed by online.githuboy.jrebel.mybatisplus.cbp.StrictMapCBP@jdk.internal.loader.ClassLoaders$AppClassLoader@38cccef: org.zeroturnaround.bundled.javassist.CannotCompileException: [source error] no such class: com.baomidou.mybatisplus.core.MybatisConfiguration$StrictMap$Ambiguity at org.zeroturnaround.bundled.javassist.expr.MethodCall.replace(SourceFile:257) at online.githuboy.jrebel.mybatisplus.cbp.StrictMapCBP$1.edit(StrictMapCBP.java:30) at org.zeroturnaround.bundled.javassist.expr.ExprEditor.loopBody(SourceFile:229) at org.zeroturnaround.bundled.javassist.expr.ExprEditor.doit(SourceFile:96) at org.zeroturnaround.bundled.javassist.CtBehavior.instrument(SourceFile:744) at online.githuboy.jrebel.mybatisplus.cbp.StrictMapCBP.process(StrictMapCBP.java:25) at org.zeroturnaround.javarebel.integration.support.JavassistClassBytecodeProcessor.process(SourceFile:145) at org.zeroturnaround.javarebel.integration.support.JavassistClassBytecodeProcessor.process(SourceFile:82) at org.zeroturnaround.javarebel.ClassBytecodeProcessor.process(SourceFile:51) at com.zeroturnaround.javarebel.yc.a(SourceFile:400) at com.zeroturnaround.javarebel.yc.a(SourceFile:340) at com.zeroturnaround.javarebel.SDKIntegrationImpl.runBytecodeProcessors(SourceFile:423) at com.zeroturnaround.javarebel.vg.transform(SourceFile:154) at com.zeroturnaround.javarebel.vg.transform(SourceFile:94) at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:43009) at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:150) at java.base/jdk.internal.loader.BuiltinClassLoader.defineClass(BuiltinClassLoader.java:862) at java.base/jdk.internal.loader.BuiltinClassLoader.findClassOnClassPathOrNull(BuiltinClassLoader.java:760) at java.base/jdk.internal.loader.BuiltinClassLoader.loadClassOrNull(BuiltinClassLoader.java:681) at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:639) at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188) at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520) at com.baomidou.mybatisplus.core.MybatisConfiguration.(MybatisConfiguration.java:65) at com.baomidou.mybatisplus.autoconfigure.MybatisPlusAutoConfiguration.applyConfiguration(MybatisPlusAutoConfiguration.java:257) at com.baomidou.mybatisplus.autoconfigure.MybatisPlusAutoConfiguration.sqlSessionFactory(MybatisPlusAutoConfiguration.java:178) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:568) at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:140) at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:644) at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:636) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1337) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1167) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:562) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:522) at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:337) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:335) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200) at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:254) at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1443) at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1353) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireByType(AbstractAutowireCapableBeanFactory.java:1503) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1412) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:599) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:522) at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:337) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:335) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200) at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:254) at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1443) at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1353) at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.autowireResource(CommonAnnotationBeanPostProcessor.java:598) at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.getResource(CommonAnnotationBeanPostProcessor.java:576) at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor$ResourceElement.getResourceToInject(CommonAnnotationBeanPostProcessor.java:738) at org.springframework.beans.factory.annotation.InjectionMetadata$InjectedElement.inject(InjectionMetadata.java:270) at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:145) at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.postProcessProperties(CommonAnnotationBeanPostProcessor.java:368) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1421) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:599) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:522) at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:337) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:335) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200) at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:254) at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1443) at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1353) at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.autowireResource(CommonAnnotationBeanPostProcessor.java:598) at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.getResource(CommonAnnotationBeanPostProcessor.java:576) at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor$ResourceElement.getResourceToInject(CommonAnnotationBeanPostProcessor.java:738) at org.springframework.beans.factory.annotation.InjectionMetadata$InjectedElement.inject(InjectionMetadata.java:270) at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:145) at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.postProcessProperties(CommonAnnotationBeanPostProcessor.java:368) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1421) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:599) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:522) at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:337) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:335) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:975) at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:962) at org.springframework.context.support.AbstractApplicationContext.__refresh(AbstractApplicationContext.java:624) at org.springframework.context.support.AbstractApplicationContext.jrLockAndRefresh(AbstractApplicationContext.java:41002) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:42008) at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:146) at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:754) at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:456) at org.springframework.boot.SpringApplication.run(SpringApplication.java:335) at com.os.StarterApplication.main(StarterApplication.java:36) Caused by: compile error: no such class: com.baomidou.mybatisplus.core.MybatisConfiguration$StrictMap$Ambiguity at org.zeroturnaround.bundled.javassist.compiler.MemberResolver.searchImports(SourceFile:479) at org.zeroturnaround.bundled.javassist.compiler.MemberResolver.lookupClass(SourceFile:422) at org.zeroturnaround.bundled.javassist.compiler.MemberResolver.lookupClassByName(SourceFile:325) at org.zeroturnaround.bundled.javassist.compiler.MemberResolver.resolveClassName(SourceFile:510) at org.zeroturnaround.bundled.javassist.compiler.MemberCodeGen.resolveClassName(SourceFile:1197) at org.zeroturnaround.bundled.javassist.compiler.CodeGen.atInstanceOfExpr(SourceFile:1489) at org.zeroturnaround.bundled.javassist.compiler.ast.InstanceOfExpr.accept(SourceFile:43) at org.zeroturnaround.bundled.javassist.compiler.CodeGen.booleanExpr(SourceFile:1240) at org.zeroturnaround.bundled.javassist.compiler.CodeGen.booleanExpr(SourceFile:1214) at org.zeroturnaround.bundled.javassist.compiler.CodeGen.booleanExpr(SourceFile:1224) at org.zeroturnaround.bundled.javassist.compiler.CodeGen.compileBooleanExpr(SourceFile:261) at org.zeroturnaround.bundled.javassist.compiler.CodeGen.atIfStmnt(SourceFile:416) at org.zeroturnaround.bundled.javassist.compiler.CodeGen.atStmnt(SourceFile:387) at org.zeroturnaround.bundled.javassist.compiler.ast.Stmnt.accept(SourceFile:53) at org.zeroturnaround.bundled.javassist.compiler.CodeGen.atStmnt(SourceFile:383) at org.zeroturnaround.bundled.javassist.compiler.ast.Stmnt.accept(SourceFile:53) at org.zeroturnaround.bundled.javassist.compiler.Javac.compileStmnt(SourceFile:578) at org.zeroturnaround.bundled.javassist.expr.MethodCall.replace(SourceFile:251) ... 92 more 提供问题复现工程(可选)

@EnableAsync
@EnableScheduling
@EnableCaching
@ServletComponentScan
@SpringBootApplication
public class StarterApplication extends SpringBootServletInitializer {
    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
        return builder.sources(StarterApplication.class);
    }

    public static void main(String[] args) {
        SpringApplication app = new SpringApplication(StarterApplication.class);

        app.run(args);
    }
}
nieqiurong commented 2 months ago

3.5.7已经移除这个了,请反馈至插件开发者。

https://github.com/baomidou/mybatis-plus/blob/v3.5.7/mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/MybatisConfiguration.java