springboot打包二次压缩Excel导致损坏

springboot打包二次压缩Excel导致损坏

开发时,将Excel文件放到resources下,通过类加载器流读取,返回api用于下载该Excel文件。我发现这样下载的Excel被损坏了,无法打开,推测是springboot打包插件默认对resources下的所有文件进行了压缩。Excel本身是一个压缩的文件,二次压缩导致损坏无法打开。

解决方案:

pom.xmlbuild中添加下面的排除过滤,PS: 我的Excel在 resources/download/xx.xlsx

xml 复制代码
<resources>
  <resource>
    <directory>src/main/resources</directory>
    <filtering>true</filtering>
    <excludes>
      <exclude>**/*.xlsx</exclude>
    </excludes>
  </resource>
  <resource>
    <directory>src/main/resources</directory>
    <filtering>false</filtering>
    <includes>
      <include>**/*.xlsx</include>
    </includes>
  </resource>
</resources>
相关推荐
Loadings39 分钟前
聊聊 AI Coding 的最新范式:Harness Engineering:我们这群程序员,又要继续学了?
前端·后端
ssshooter41 分钟前
哈希是怎么被破解的?
前端·后端
荒古前1 小时前
Spring Boot + MyBatis 启动报错:不允许有匹配 “[xX][mM][lL]“ 的处理指令目标
spring boot·后端·mybatis
mldlds1 小时前
Spring Boot 实战:轻松实现文件上传与下载功能
java·数据库·spring boot
xxjj998a1 小时前
Spring Boot 整合 Apollo 配置中心实战
java·spring boot·后端
苏三说技术1 小时前
千万数量级excel,如何快速导入?
后端
徐小夕1 小时前
一个普通Word文档,为什么99%的开源编辑器都"认怂"了?我们选择正面硬刚
vue.js·后端·github
splage1 小时前
SpringBoot 与 SpringCloud的版本对应详细版
spring boot·后端·spring cloud
不是株1 小时前
SpringCloud
后端·spring·spring cloud
wellc2 小时前
Spring Boot 热部署
java·spring boot·后端