The requirement is to provide an interface to download the file template and start to retrieve the file in the way of classloader. There is no problem with running locally, but it can’t be done by typing it into jar. What you get is a bunch of paths containing.
The following methods can be used locally or as jar:
String filename = "templates/template.xlsx"; ClassPathResource classPathResource = new ClassPathResource("templates/template.xlsx"); InputStream inputStream = classPathResource.getInputStream();