Java Maven 编译资源文件拷贝错误 dirCompressed.zip failed with MalformedInputException:

完整的错误信息为:

复制代码
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:3.3.1:resources (default-resources) on project core-java-io: filtering C:\WorkDir\Repository\iSharkfly-Docs\java-tutorials\core-java-modules\core-java-io\src\main\resources\dirCompressed.zip to C:\WorkDir\Repository\iSharkfly-Docs\java-tutorials\core-java-modules\core-java-io\target\classes\dirCompressed.zip failed with MalformedInputException: Input length = 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
[ERROR]
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR]   mvn <args> -rf :core-java-io

问题和解决

出现上面错误的原因是在资源文件进行拷贝的时候的校验问题。

我们需要拷贝一个 zip 的资源文件,但是 Maven 在拷贝的时候会进行校验,这会导致拷贝失败。

所以我们可以添加配置:

复制代码
                    <nonFilteredFileExtensions>
                        <nonFilteredFileExtension>zip</nonFilteredFileExtension>
                    </nonFilteredFileExtensions>

到 插件 maven-resources-plugin 中。

添加后的完整插件配置为:

复制代码
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-resources-plugin</artifactId>
                <version>${maven-resources-plugin.version}</version>
                <configuration>
                    <encoding>UTF-8</encoding>
                    <nonFilteredFileExtensions>
                        <nonFilteredFileExtension>zip</nonFilteredFileExtension>
                    </nonFilteredFileExtensions>
                </configuration>
            </plugin>

当完成上面的配置后,资源文件就可以顺利在编译的时候拷贝了。

Java Maven 编译资源文件拷贝错误 dirCompressed.zip failed with MalformedInputException: - Java - iSharkFly完整的错误信息为: ERROR Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:3.3.1:resources (default-resources) on project core-java-io: filtering C:\WorkDir\Repository\iSharkfly-Docs\java-tutorials\core-ja...https://www.isharkfly.com/t/java-maven-dircompressed-zip-failed-with-malformedinputexception/15694

相关推荐
砍材农夫1 分钟前
物联网实战|Spring Boot + Netty 搭建 MQTT 消息路由与流转层
java·spring boot·后端·物联网·spring
黄毛火烧雪下5 分钟前
Java 基础笔记:文件、递归与字符编码
java·开发语言·笔记
学计算机的计算基7 分钟前
链表算法上篇:LeetCode 206/234/141/142/160/21 题解与易错点
java·笔记·算法·链表
信也科技布道师9 分钟前
从Istio 503 NC 错误深入理解 Mesh 路由全链路原理
java·服务器·网络
swordbob13 分钟前
3 大 I/O 模型BIO / NIO / AIO
java·linux·spring
Pluto_CSND14 分钟前
Cron表达式使用说明
java
十五喵源码网14 分钟前
基于SpringBoot2+vue2的酒店客房管理系统
java·毕业设计·springboot·论文笔记
swordbob28 分钟前
CAP 定理:为什么不能同时实现 C、A、P?
开发语言·后端·spring
疯狂成瘾者28 分钟前
Java 常用工具包 java.util
java·开发语言·windows
枫叶丹429 分钟前
【HarmonyOS 6.0】MDM Kit 新特性:PC/2in1设备无锁屏密码重启自动解锁能力详解
开发语言·华为·harmonyos