首页 > 解决方案 > Spring Boot 获取 java.util.zip.ZipException:设置的代码长度无效

问题描述

我正在使用 Spring boot 2.1.1.RELEASE 和 castor 1.2。它开始正常,按预期工作了几个小时,然后突然开始出现以下错误 -

o.c.c.u.Configuration                    : Failed to load configuration from classpath: /org/castor/core/castor.core.properties
java.util.zip.ZipException: invalid code lengths set
        at java.util.zip.InflaterInputStream.read(InflaterInputStream.java:164)
        at org.springframework.boot.loader.jar.ZipInflaterInputStream.read(ZipInflaterInputStream.java:52)
        at java.io.FilterInputStream.read(FilterInputStream.java:107)
        at java.util.Properties$LineReader.readLine(Properties.java:435)
        at java.util.Properties.load0(Properties.java:353)
        at java.util.Properties.load(Properties.java:341)
        at org.castor.core.util.Configuration.loadFromClassPath(Configuration.java:187)
        at org.castor.core.util.Configuration.loadDefaultProperties(Configuration.java:136)
        at org.castor.core.CoreConfiguration.<init>(CoreConfiguration.java:49)
        at org.castor.xml.XMLConfiguration.newInstance(XMLConfiguration.java:58)
        at org.castor.xml.AbstractInternalContext.<init>(AbstractInternalContext.java:121)
        at org.castor.xml.BackwardCompatibilityContext.<init>(BackwardCompatibilityContext.java:45)
        at org.exolab.castor.xml.Unmarshaller.<init>(Unmarshaller.java:206)

jar 存在于 BOOT-INF\lib\castor-1.2.jar\

我们是否需要将 /org/castor/core/castor.core.properties 放在类路径中的某个位置来解决此问题?请建议

标签: springspring-bootcastor

解决方案


通常应该有一个默认的属性文件。正如手册在https://castor-data-binding.github.io/castor/reference-guide/reference/xml/xml-properties.html上所说,您可以在类路径中提供该文件。


推荐阅读