After the springboot project is typed into jar, read the file under resource

Time:2020-9-23

After the springboot project is typed into jar, read the file under resource

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();

Recommended Today

Queue chain storage

Linked list realizes queue Create three files: queuelinked. H, queuelinked. C, queuelinkedtest. C queueLinked.h #ifndef QUEUE_LINKED_H_ #define QUEUE_LINKED_H_ #ifdef __GNUC__ #define DEPRECATED __attribute__( (deprecated) ) #elif defined(_MSC_VER) #define DEPRECATED __declspec( deprecated ) #else #define DEPRECATED #endif #ifndef PTOI #define PTOI( p ) ((int32_t)(int64_t)(p)) #endif #ifndef ITOP #define ITOP( i ) ((void *)(int64_t)(i)) #endif #define ADT […]