Created
September 10, 2020 06:05
-
-
Save rlcc885/d46af86364e89b24910d5768a32f628d to your computer and use it in GitHub Desktop.
Load Resource from inner folder (Spring boot)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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