web项目下classpath文件获取
方式一:
package org.springframework.util;
File file = ResourceUtils.getFile("classpath:orgmapping.json");
方式二:
package org.springframework.core.io;
Resource resourcefile = new ClassPathResource("orgmapping.json");
File file = resourcefile.getFile();
InputStream inputStream = resourcefile.getInputStream();
方式三:
import org.apache.commons.io.IOUtils;
@Value("classpath:test.json")
private org.springframework.core.io.Resource resource;
String json = IOUtils.toString(resource.getInputStream(), StandardCharsets.UTF_8);
方式四:
public static void parseProperties(String filePath) throws IOException {
ClassPathResource resource = new ClassPathResource(quartzFile);
Properties props = new Properties();
props.load(resource.getInputStream());
properties.getProperty("你的配置名称");
}