执行Maven Install打包的时候,出现以下错误信息:
[proguard] ProGuard, version 4.4
[proguard] Reading input...
[proguard] Reading program war [F:\Workspaces\pro-test\target\pro-test-0.0.1-SNAPSHOT.war] (filtered)
[proguard] java.io.IOException: Can‘t read [[email protected]5ef04b5] (Can‘t process class [WEB-INF/classes/pro/test/First.class] (Unsupported version number [52.0] for class format))
[proguard] at proguard.InputReader.readInput(InputReader.java:230)
[proguard] at proguard.InputReader.readInput(InputReader.java:200)
[proguard] at proguard.InputReader.readInput(InputReader.java:178)
[proguard] at proguard.InputReader.execute(InputReader.java:78)
[proguard] at proguard.ProGuard.readInput(ProGuard.java:195)
[proguard] at proguard.ProGuard.execute(ProGuard.java:78)
[proguard] at proguard.ProGuard.main(ProGuard.java:499)
问题分析
产生该错误的原因是因为项目使用的Java(JDK)版本比较高,而ProGuard, version 4.4支持的版本(最高到1.6),所以产生该问题。
解决方案
以问题的解决方案与“Error: Unsupported java version ‘1.8’ in line 2 of file ‘proguard.conf’”的一致:
改用com.github.wvengen的proguard-maven-plugin
repo地址为:http://repo1.maven.org/maven2/com/github/wvengen/proguard-maven-plugin/
完整示例如下:
<plugin>
<groupId>com.github.wvengen</groupId>
<artifactId>proguard-maven-plugin</artifactId>
<version>2.0.10</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>proguard</goal>
</goals>
</execution>
</executions>
<configuration>
<proguardVersion>5.2</proguardVersion>
<obfuscate>true</obfuscate>
<proguardInclude>${basedir}/proguard.conf</proguardInclude>
<!-- 添加依赖,这里你可以按你的需要修改 -->
<libs>
<lib>${java.home}/lib/rt.jar</lib>
<lib>E:/tomcat-8.0/lib/jsp-api.jar</lib>
<lib>E:/tomcat-8.0/lib/servlet-api.jar</lib>
</libs>
<addMavenDescriptor>false</addMavenDescriptor>
<injar>${project.build.finalName}.war</injar>
<outjar>${project.build.finalName}-pg.war</outjar>
<outputDirectory>${project.build.directory}</outputDirectory>
</configuration>
<dependencies>
<!-- 使用5.2版本来混淆 -->
<dependency>
<groupId>net.sf.proguard</groupId>
<artifactId>proguard-base</artifactId>
<version>5.2</version>
<scope>runtime</scope>
</dependency>
</dependencies>
</plugin>
java.io.IOException: Can't read [[email protected]] (Can't process class [WEB-INF/clas
时间: 2024-10-12 13:31:16