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

相关推荐
Code哈哈笑3 分钟前
【JavaEE】SpringBoot快速上手,探秘 Spring Boot,搭建 Java 项目的智慧脚手架
java·spring boot·java-ee
Seven9711 分钟前
【设计模式】从火车站卖票看代理模式的实际应用
java·后端·设计模式
我的运维人生12 分钟前
从零开始:使用 Python 实现机器学习的基础与实践
开发语言·python·机器学习
A阳俊yi22 分钟前
SpringMVC概述以及入门案例
java·spring
2301_7891695424 分钟前
JSON.parse(JSON.stringify())深拷贝不会复制函数
开发语言·前端·javascript
恋恋风辰25 分钟前
QT系列教程(17) MVC结构之Model模型介绍
开发语言·qt·mvc
开开心心就好36 分钟前
能一站式搞定远程操作需求的实用工具
java·服务器·python·spring·pdf·电脑·软件
冬天vs不冷42 分钟前
Spring组件实例化扩展点:InstantiationAwareBeanPostProcessor
java·后端·spring
熊峰峰1 小时前
数据结构第八节:红黑树(初阶)
开发语言·数据结构·c++·算法
上官美丽1 小时前
Maven Deploy Plugin如何使用?
java·maven