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

相关推荐
AKA__Zas3 分钟前
初识多线程(3.0)
java·开发语言·学习方法
小杍随笔10 分钟前
【Rust 工具链管理工具再升级!rust-verse v1.3.1 ~ v1.3.5 最新更新深度解析】
开发语言·后端·rust
北漂人Java15 分钟前
SpringAI-2.Spring AI整合本地模型和云端大模型
java·spring
迹象Kimizhou_blog17 分钟前
国内 IntelliJ IDEA 集成Claude code,调用deepSeek模型实现agent
java·ide·intellij-idea·deepseek·claude code
大数据三康28 分钟前
在spyder进行的遗传算法练习
开发语言·python·算法
百珏28 分钟前
海量人群包存储优化:基于 RoaringBitmap 交换格式与 Redis 分片 Bitmap 的实践
java·后端·架构
风味蘑菇干28 分钟前
IO流(字节流)
java
Vallelonga32 分钟前
Rust 从结构体中取字段的引用
开发语言·rust
社交怪人1 小时前
【球体体积】信息学奥赛一本通C语言解法(题号1030)
c语言·开发语言
froginwe111 小时前
Foundation 顶部导航栏详解
开发语言