简体   繁体   中英

How to pick up a file from resources folder of maven directory structure in a spring boot application?

How to pick up a file from resources folder of maven without specifying path? Is there a configuration file from which I can pick up the address?

You can check ResourceUtils class. For example if you want to read a json file:

private final static TypeReference<Map<String, String>> typeReference = new TypeReference<Map<String, String>>() {
};
Map<String, String> map = 
mapper.readValue(ResourceUtils.getURL("classpath:some.json").openStream(), typeReference);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM