Can't process class [META-INF/versions/9/org/apache/logging/log4j/util/ProcessIdUtil.class] (Unsuppo

最近在做Spring 升级SpringBoot 的项目工作遇到了混淆的一个坑

错误:Can't process class [META-INF/versions/9/org/apache/logging/log4j/util/ProcessIdUtil.class] (Unsupported class version number [53.0] (maximum 52.0, Java 1.8))

到网上搜索的答案是:

要解决报错需屏蔽log4j中使用java9 api的类。在proguard的配置文件中log4j-api-2.10.0.jar后面加入(!META-INF/versions/9/**.class,!module-info.class)

配置文件示例

-libraryjars lib\log4j-api-2.10.0.jar(!META-INF/versions/9/**.class,!module-info.class)

-libraryjars lib\log4j-core-2.10.0.jar

-libraryjars lib\log4j-jcl-2.10.0.jar

-libraryjars lib\log4j-web-2.10.0.jar

后来我添加了,还是不行,因为maven 会从我的本地仓库去获取jar包,所以这个lib\....jar路径是错误的,需要修改你你本地的maven仓库地址,同时在中添加api的排除;


        
             log4j-api
             org.apache.logging.log4j
        

这种方式不推荐;

后面我去GitHub看了一下直接修改progurad的版本号,让其支持jdk1.8以及更好版本;

            
                com.github.wvengen
                proguard-maven-plugin
                2.0.14
                
                    
                        package
                        
                            proguard
                        
                    
                
                
                    6.0.2
                    true
                    
                    true
                    
                    true
                    
                    pg
                    ./proguard.cfg
                    
                        ${java.home}/lib/rt.jar
                        ${java.home}/lib/jce.jar
                    
                    false
                    ${project.build.finalName}.jar
                    ${project.build.finalName}-pg.jar
                    ${project.build.directory}

                    
                
                
                    
                        net.sf.proguard
                        proguard-base
                        6.0.2
                        runtime
                    
                
            

配置文件的progurad.cfg的配置文件直接放在项目根目录下

# 这里的配置根据自己的项目需要进行添加,这里我只是一个例子
-target 1.8
-dontshrink
-dontoptimize
-useuniqueclassmembernames
-adaptclassstrings
-ignorewarnings
-dontusemixedcaseclassnames
-keepattributes Exceptions,InnerClasses,Signature,Deprecated,SourceFile,LineNumberTable,*Annotation*,EnclosingMethod
-keepclasseswithmembers public class * { public static void main(java.lang.String[]);}
#-libraryjars /Users/mac/.m2/repository/org/apache/logging/log4j/log4j-api/2.10.0/log4j-api-2.10.0.jar(!META-INF/versions/9/**.class,!module-info.class)

 

你可能感兴趣的:(SpringBoot系列)