cqc3073
12/22/2017 - 2:52 AM

加载jar包资源文件

通过spring加载jar包中的资源文件

Resource[] resources = applicationContext.getResources("classpath:**/*.sql");
for (Resource resource : resources) {
    String sql = CharStreams.toString(new InputStreamReader(resource.getInputStream(), StandardCharsets.UTF_8));
}

//也可直接使用ClassPathResource来加载,用于获取单个的资源文件
ClassPathResource classPathResource = new ClassPathResource("xxx.properties");