未能初始化excel reader-spring批处理作业
我写了一个作业来读取基于github项目spring扩展excel的excel文件 代码如下:未能初始化excel reader-spring批处理作业,spring,spring-batch,Spring,Spring Batch,我写了一个作业来读取基于github项目spring扩展excel的excel文件 代码如下: <bean id="VignetteItemReader" class="excel.poi.PoiItemReader"> <property name="resource" value="Vignettes.xlsx" /> <property name="rowMapper"> <bean class="excel.mapping.PassThr
<bean id="VignetteItemReader" class="excel.poi.PoiItemReader">
<property name="resource" value="Vignettes.xlsx" />
<property name="rowMapper">
<bean class="excel.mapping.PassThroughRowMapper" />
</property>
</bean>
但我面临着这个错误:
org.springframework.batch.item.ItemStreamException:未能初始化读取器
它告诉我这是由以下原因引起的:
java.util.zip.ZipException:无效的块类型
PS:xls文件正确显示为红色,问题是当我使用扩展名:.xlsx时
有什么建议吗?我找到了解决方案,这是一个与pom.xml有关的配置: 我应该添加以下标签:
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
<excludes>
<exclude>**/*.xml</exclude>
<exclude>**/*.xlsx</exclude>
<exclude>**/*.xls</exclude>
<exclude>**/*.csv</exclude>
</excludes>
</resource>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
<includes>
<include>**/*.version</include>
<include>**/*.properties</include>
<include>**/*.xml</include>
</includes>
</resource>
<resource>
<directory>src/main/resources</directory>
<filtering>false</filtering>
<includes>
<include>**/*.xml</include>
<include>**/*.xlsx</include>
<include>**/*.xls</include>
<include>**/*.csv</include>
</includes>
</resource>
</resources>
<testResources>
<testResource>
<directory>src/test/resources</directory>
<filtering>true</filtering>
</testResource>
</testResources>
src/main/resources
真的
**/*.xml
**/*.xlsx
**/*.xls
**/*.csv
src/main/resources
真的
**/*.版本
**/*.物业
**/*.xml
src/main/resources
假的
**/*.xml
**/*.xlsx
**/*.xls
**/*.csv
src/测试/资源
真的
提供指向该github项目的链接,很可能读者无法找到使用资源指定的文件。如果您的类路径中的该文件不存在stacktrace,则尝试类似value=classpath:Vignettes.xlsx“
的操作。如果没有stacktrace,则很困难,但资源属性值可能是错误的;添加完整的文件路径或类路径:\I dnt认为是这样。错误不是由类路径引起的:/