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>
相关推荐
ShadowYD1 小时前
Agent Loop:一个让 AI 编程 Agent 从"会写代码"进化到"闭环交付"的开源 Skill(适配国内外主流 Code Agent)
后端
考虑考虑2 小时前
nohup启动java程序
后端·自动化运维
aramae3 小时前
模拟实现strcmp()(C语言)
c语言·开发语言·后端
+VX:Fegn08954 小时前
计算机毕业设计|基于springboot + vue蛋糕店管理系统(源码+数据库+文档)
前端·数据库·vue.js·spring boot·课程设计
根目录下的猫6 小时前
RK3588适配的轻量级AI模型推荐
人工智能·后端·python·目标检测
wno7046 小时前
Spring Boot整合Kafka
spring boot·kafka
星栈6 小时前
用 Rust 写 Agent 服务 -- adk-rust 上手记
后端·agent
杨运交7 小时前
[071][验证码模块]基于Spring拦截器的验证码认证设计思想
java·后端·spring
LucianaiB7 小时前
我用豆包工作 Seed-2.1-pro,复刻了 QQ 时代爆红的魔术图片
后端