The requirement is to provide a download file template interface, local run no problem, but into JAR is not good, get a bunch of contains! The path. The following methods can be jarded locally or not:

 String filename = "templates/template.xlsx";
    ClassPathResource classPathResource = new ClassPathResource("templates/template.xlsx");
    InputStream inputStream = classPathResource.getInputStream();

If you are using a ClassLoader or ClassLoader to read a file in a JAR, you can only use a stream to read the file, not a file. The file must have a path.

BufferedReader in = new BufferedReader(new InputStreamReader(AuditConstant.class.getClassLoader().getResourceAsStream("xxx"))); StringBuffer buffer = new StringBuffer(); String line = ""; while ((line = in.readLine()) ! = null){ buffer.append(line); }