java.io.IOException: The input doesn't contain any classes. Did you specify the proper '-injars' opt

简介: 问题场景在使用Maven + Proguard打包项目进行混淆时,提示以下错误:[proguard] ProGuard, version 4.4 [proguard] Reading input.

问题场景


在使用Maven + Proguard打包项目进行混淆时,提示以下错误:

[proguard] ProGuard, version 4.4
 [proguard] Reading input...
 [proguard] java.io.IOException: The input doesn't contain any classes. Did you specify the proper '-injars' options?
 [proguard]     at proguard.InputReader.execute(InputReader.java:91)
 [proguard]     at proguard.ProGuard.readInput(ProGuard.java:195)
 [proguard]     at proguard.ProGuard.execute(ProGuard.java:78)
 [proguard]     at proguard.ProGuard.main(ProGuard.java:499)

问题分析


缺少injars配置项!
-injars {class_path} 指定要处理的应用程序jar,war,ear和目录

解决方案


添加injars配置项,由于是Web项目,所以这里指定的是war

<injar>${project.build.finalName}.war</injar>

完整示例:

            <plugin>
                <groupId>com.pyx4me</groupId>
                <artifactId>proguard-maven-plugin</artifactId>
                <version>2.0.4</version>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>proguard</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <obfuscate>true</obfuscate>
                    <proguardInclude>${basedir}/proguard.conf</proguardInclude>
                    <!-- 添加依赖,这里你可以按你的需要修改 -->
                    <libs>
                        <lib>${java.home}/lib/rt.jar</lib>
                        <lib>lib/jsp-api.jar</lib>
                        <lib>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> 
                    <!-- 使用4.4版本来混淆 -->
                    <dependency>
                        <groupId>net.sf.proguard</groupId>
                        <artifactId>proguard</artifactId>  
                        <version>4.4</version>
                        <scope>runtime</scope>
                    </dependency>
                </dependencies>
            </plugin>
目录
相关文章
启动报错:java.nio.charset.MalformedInputException: Input length = 1
启动报错:java.nio.charset.MalformedInputException: Input length = 1
1552 0
|
Java API 开发工具
【Azure Developer】Java代码实现获取Azure 资源的指标数据却报错 "invalid time interval input"
在使用 Java 调用虚拟机 API 获取指标数据时,因本地时区设置非 UTC,导致时间格式解析错误。解决方法是在代码中手动指定时区为 UTC,使用 `ZoneOffset.ofHours(0)` 并结合 `withOffsetSameInstant` 方法进行时区转换,从而避免因时区差异引发的时间格式问题。
469 4
|
Java 数据处理
Java IO 接口(Input)究竟隐藏着怎样的神秘用法?快来一探究竟,解锁高效编程新境界!
【8月更文挑战第22天】Java的输入输出(IO)操作至关重要,它支持从多种来源读取数据,如文件、网络等。常用输入流包括`FileInputStream`,适用于按字节读取文件;结合`BufferedInputStream`可提升读取效率。此外,通过`Socket`和相关输入流,还能实现网络数据读取。合理选用这些流能有效支持程序的数据处理需求。
803 2
Java系列之 For input string: ““
这篇文章讨论了Java中因尝试将空字符串转换为其它数据类型(如int)时出现的`For input string: ""`错误,并提供了通过非空检查来避免此错误的解决方法。
|
XML Java 数据库连接
Mybatis java.lang.NumberFormatException: For input string: "1,2" 问题处理
【8月更文挑战第9天】Mybatis java.lang.NumberFormatException: For input string: "1,2" 问题处理
|
存储 Java
java IO接口(Input)用法
【5月更文挑战第1天】Java的`java.io`包包含多种输入输出类。此示例展示了如何使用`FileInputStream`从`input.txt`读取数据。首先创建`FileInputStream`对象,接着创建一个字节数组存储读取的数据,调用`read()`方法将文件内容填充至数组。然后将字节数组转换为字符串并打印,最后关闭输入流。注意,`InputStream`是抽象类,此处使用其子类`FileInputStream`。其他子类如`ByteArrayInputStream`、`ObjectInputStream`和`BufferedInputStream`各有特定用途。
355 2
|
Java Linux Nacos
Java -jar 运行 报 MalformedInputException: Input length = 1
Java -jar 运行 报 MalformedInputException: Input length = 1
750 0
Swagger2异常:java.lang.NumberFormatException: For input string: ““
Swagger2异常:java.lang.NumberFormatException: For input string: ““
265 1
|
Java Spring
解决org.yaml.snakeyaml.error.YAMLException: java.nio.charset.MalformedInputException: Input length = 2
解决org.yaml.snakeyaml.error.YAMLException: java.nio.charset.MalformedInputException: Input length = 2
1839 1
|
Scala
scala 读取文件(中文)异常 thread "main" java.nio.charset.MalformedInputException: Input length = 1
scala 读取文件(中文)异常 thread "main" java.nio.charset.MalformedInputException: Input length = 1
288 0