spring boot引起:java.lang.UnsupportedOperationException:不支持的类版本号[53.0](最大52.0,Java 1.8)

时间:2018-01-13 12:18:36

标签: java spring-boot proguard obfuscation

我目前正在开发一个Spring Boot项目,我打算用 Proguard 进行混淆。一切正常。但是当我尝试打包应用程序时,我收到了 Proguard 错误

    (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)))
 [proguard]     at proguard.InputReader.readInput(InputReader.java:188)
 [proguard]     at proguard.InputReader.readInput(InputReader.java:158)
 [proguard]     at proguard.InputReader.readInput(InputReader.java:136)
 [proguard]     at proguard.InputReader.execute(InputReader.java:88)
 [proguard]     at proguard.ProGuard.readInput(ProGuard.java:218)
 [proguard]     at proguard.ProGuard.execute(ProGuard.java:82)
 [proguard]     at proguard.ProGuard.main(ProGuard.java:538)
 [proguard] Caused by: java.io.IOException: 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))
 [proguard]     at proguard.io.ClassReader.read(ClassReader.java:112)
 [proguard]     at proguard.io.FilteredDataEntryReader.read(FilteredDataEntryReader.java:87)
 [proguard]     at proguard.io.FilteredDataEntryReader.read(FilteredDataEntryReader.java:87)
 [proguard]     at proguard.io.JarReader.read(JarReader.java:65)
 [proguard]     at proguard.io.DirectoryPump.readFiles(DirectoryPump.java:65)
 [proguard]     at proguard.io.DirectoryPump.pumpDataEntries(DirectoryPump.java:53)
 [proguard]     at proguard.InputReader.readInput(InputReader.java:184)
 [proguard]     ... 6 more
 [proguard] Caused by: java.lang.UnsupportedOperationException: Unsupported class version number [53.0] (maximum 52.0, Java 1.8)
 [proguard]     at proguard.classfile.util.ClassUtil.checkVersionNumbers(ClassUtil.java:145)
 [proguard]     at proguard.classfile.io.LibraryClassReader.visitLibraryClass(LibraryClassReader.java:89)
 [proguard]     at proguard.classfile.LibraryClass.accept(LibraryClass.java:306)
 [proguard]     at proguard.io.ClassReader.read(ClassReader.java:86)
 [proguard]     ... 12 more
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 01:22 min
[INFO] Finished at: 2018-01-13T13:10:43+01:00
[INFO] Final Memory: 26M/281M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.github.wvengen:proguard-maven-plugin:2.0.14:proguard (default) on project ESMANSOFT: Obfuscation failed (result=1) -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

我尝试了很多选项,但没有任何效果。我甚至尝试升级到Java 9,但被告知proguard不支持java 9.我使用的是proguard 5.3.3。什么是最好的出路?提前谢谢。

2 个答案:

答案 0 :(得分:0)

在整理了用户的贡献之后,我终于使用了proguard jar文件的本地副本并且它工作了!!!我创建了一个文件夹resources/libs/proguard/并将最新的proguard.jar放入其中。在这种情况下proguard6.0beta1。这是proguard配置

 <plugin>
            <groupId>com.github.wvengen</groupId>
<artifactId>proguard-maven-plugin</artifactId>

            <executions>
                <execution>
                    <phase>package</phase>
                    <goals><goal>proguard</goal></goals>
                </execution>
            </executions>
            <configuration>
                <proguardVersion>6.0beta1</proguardVersion>
                <injar>${project.build.finalName}.jar</injar>
                <outjar>${project.build.finalName}.jar</outjar>
                <obfuscate>true</obfuscate>
                <proguardInclude>${basedir}/proguard.conf</proguardInclude>
                <libs>
                    <!-- Include main JAVA library required.-->
                    <lib>${java.home}/lib/rt.jar</lib>
                    <!-- Include crypto JAVA library if necessary.-->
                    <lib>${java.home}/lib/jce.jar</lib>

                    <lib>${java.home}/lib/jsse.jar</lib>
                </libs>
            </configuration>
            <dependencies>
                <dependency>
                    <groupId>net.sf.proguard</groupId>
                    <artifactId>proguard-base</artifactId>
                    <version>6.0beta1</version>
                        <scope>system</scope>
        <systemPath>${basedir}/src/main/resources/libs/proguard/proguard.jar</systemPath>
                </dependency>
            </dependencies>

万分感谢!

答案 1 :(得分:-1)

我也遇到了你的问题!幸运的是,问题已解决。

<exclusions>
    <exclusion>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-logging</artifactId>
    </exclusion>
</exclusions>

在spring-boot-starter依赖项中添加它,排除默认的日志框架。

它可以解决我的问题,但我不知道为什么。