方法1: 通过@Value注解获取Resouces对象

image.png

  1. @Value("classpath:template/品牌规格型号模板.xlsx")
  2. private Resource temp;

方法2:通过新建ClassPathResource

String fileName = "品牌规格型号模板.xlsx";//这个fileName可以通过接口参数传入
ClassPathResource classPathResource = new ClassPathResource("template/" + fileName);