分离依懒jar包,mybatis plus 的lambda表达式报错

Blade 未结 1 1142
312237823
312237823 2021-03-25 08:35

一、该问题的重现步骤是什么?

  1. 分离依懒jar包的打包方式,pom里build标签下的内容如下

  2. 
        esr
        
            
                src/main/resources
            
            
                src/main/java
                
                    **/*.xml
                
            
        
        
            
                
                    org.springframework.boot
                    spring-boot-maven-plugin
                    ${spring.boot.version}
                    
                        ${project.build.finalName}
                    
                    
                        
                            
                                repackage
                            
                        
                    
                
                
                    com.spotify
                    docker-maven-plugin
                    ${docker.plugin.version}
                    
                        ${docker.registry.url}/blade/${project.artifactId}:${project.version}
                        ${project.basedir}
                        ${docker.registry.host}
                        
                            
                                /
                                ${project.build.directory}
                                ${project.build.finalName}.jar
                            
                        
                        ${docker.registry.url}
                        ${docker.registry.url}
                        true
                    
                
            
        
        
            
            
                org.apache.maven.plugins
                maven-jar-plugin
                
                    
                    
                        *.**
                        */*.xml
                        *.properties
                        *.yml
                        */*.properties
                        */*.yml
                    
                    
                        
                            
                            true
                            
                            
                            lib/
                            
                            false
                            
                            org.springblade.Application
                        
                        
                            
                            
                            ./resources/
                        
                    
                    ${project.build.directory}
                
            
    
            
            
                org.apache.maven.plugins
                maven-dependency-plugin
                
                    
                        copy-dependencies
                        package
                        
                            copy-dependencies
                        
                        
                            
                                ${project.build.directory}/lib/
                            
                        
                    
                
            
    
            
            
                maven-resources-plugin
                
                    
                        copy-resources
                        package
                        
                            copy-resources
                        
                        
                            
                                
                                    src/main/resources
                                    
                                        *.properties
                                        *.yml
                                        */*.properties
                                        */*.properties
                                        **/*.xml
                                    
                                
                                
                                    src/main/java
                                    
                                        **/*.xml
                                    
                                
                            
                            ${project.build.directory}/resources
                        
                    
                
            
    
            
            
                org.springframework.boot
                spring-boot-maven-plugin
                
                    
                    
                        
                            non-exists
                            non-exists
                        
                    
                    ZIP
                    
                    true
                    ${project.build.directory}
                
                
                    
                        
                            repackage
                        
                        
                            
                            
                            
                        
                    
                
            
            
                maven-compiler-plugin
                ${maven.plugin.version}
                
                    ${java.version}
                    ${java.version}
                    UTF-8
                    
                        -parameters
                    
                
            
            
            
                org.apache.maven.plugins
                maven-surefire-plugin
                
                    true
                
            
        
    
    

2. 打完包后,正常启动,但只要是用到mybatis-plus 的lambda表达式的地方,都报错,报错如下:

java.lang.IllegalStateException: Failed to execute CommandLineRunner
        at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:784)
        at org.springframework.boot.SpringApplication.callRunners(SpringApplication.java:765)
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:319)
        at org.springframework.boot.builder.SpringApplicationBuilder.run(SpringApplicationBuilder.java:140)
        at org.springblade.core.launch.BladeApplication.run(BladeApplication.java:49)
        at org.springblade.Application.main(Application.java:34)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48)
        at org.springframework.boot.loader.Launcher.launch(Launcher.java:87)
        at org.springframework.boot.loader.Launcher.launch(Launcher.java:51)
        at org.springframework.boot.loader.PropertiesLauncher.main(PropertiesLauncher.java:578)
Caused by: com.baomidou.mybatisplus.core.exceptions.MybatisPlusException: This is impossible to happen
        at com.baomidou.mybatisplus.core.toolkit.ExceptionUtils.mpe(ExceptionUtils.java:39)
        at com.baomidou.mybatisplus.core.toolkit.support.SerializedLambda.resolve(SerializedLambda.java:67)
        at com.baomidou.mybatisplus.core.toolkit.LambdaUtils.lambda$resolve$0(LambdaUtils.java:64)
        at java.util.Optional.orElseGet(Unknown Source)
        at com.baomidou.mybatisplus.core.toolkit.LambdaUtils.resolve(LambdaUtils.java:63)
        at com.baomidou.mybatisplus.core.conditions.AbstractLambdaWrapper.columnToString(AbstractLambdaWrapper.java:63)
        at com.baomidou.mybatisplus.core.conditions.AbstractLambdaWrapper.columnToString(AbstractLambdaWrapper.java:59)
        at com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper.set(LambdaUpdateWrapper.java:92)
        at com.baomidou.mybatisplus.extension.conditions.update.LambdaUpdateChainWrapper.set(LambdaUpdateChainWrapper.java:45)
        at com.baomidou.mybatisplus.extension.conditions.update.LambdaUpdateChainWrapper.set(LambdaUpdateChainWrapper.java:31)
        at com.baomidou.mybatisplus.core.conditions.update.Update.set(Update.java:30)
        at org.springblade.modules.socket.runner.ServerRunner.run(ServerRunner.java:37)
        at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:781)
        ... 13 common frames omitted
Caused by: java.lang.ClassNotFoundException: org.springblade.modules.socket.runner.ServerRunner
        at java.net.URLClassLoader.findClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Unknown Source)
        at java.io.ObjectInputStream.resolveClass(Unknown Source)
        at com.baomidou.mybatisplus.core.toolkit.support.SerializedLambda$1.resolveClass(SerializedLambda.java:61)
        at java.io.ObjectInputStream.readNonProxyDesc(Unknown Source)
        at java.io.ObjectInputStream.readClassDesc(Unknown Source)
        at java.io.ObjectInputStream.readClass(Unknown Source)
        at java.io.ObjectInputStream.readObject0(Unknown Source)
        at java.io.ObjectInputStream.defaultReadFields(Unknown Source)
        at java.io.ObjectInputStream.readSerialData(Unknown Source)
        at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
        at java.io.ObjectInputStream.readObject0(Unknown Source)
        at java.io.ObjectInputStream.readObject(Unknown Source)
        at java.io.ObjectInputStream.readObject(Unknown Source)
        at com.baomidou.mybatisplus.core.toolkit.support.SerializedLambda.resolve(SerializedLambda.java:65)
        ... 24 common frames omitted


二、你期待的结果是什么?实际看到的又是什么?

分离jar包,减小主包的大小,

三、你正在使用的是什么产品,什么版本?在什么操作系统上?

bladex boot项目,2.4.0.RELEASE,win环境

四、请提供详细的错误堆栈信息,这很重要。


五、若有更多详细信息,请在下面提供。

1条回答
  •  admin
    admin (楼主)
    2021-03-25 11:08

    Caused by: java.lang.ClassNotFoundException: org.springblade.modules.socket.runner.ServerRunner

    主要报错原因是找不到你的类,这个还是与配置有关,你不要把mybatis-plus的包分离出去

    作者追问:2021-03-25 11:08

    怎么排除mybatis的包?具体怎么配置?

    0 讨论(0)
提交回复