Skip to content

Instantly share code, notes, and snippets.

@rlcc885
Created September 10, 2020 06:05
Show Gist options
  • Select an option

  • Save rlcc885/d46af86364e89b24910d5768a32f628d to your computer and use it in GitHub Desktop.

Select an option

Save rlcc885/d46af86364e89b24910d5768a32f628d to your computer and use it in GitHub Desktop.
Load Resource from inner folder (Spring boot)
public class LoadResourceInsideJar {
// ...
@PostConstruct
public void init() {
try {
Resource resource = resourceLoader.getResource("classpath:emailTemplate.html");
InputStream resourceAsStream = resource.getInputStream(); // <-- this is the difference (Jar Embedded)
} catch (IOException | NullPointerException e) {
LOGGER.error("Resource couldn't be loaded. ", e);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment