I am trying to get hold of a file ( or a directory ) under /WEB-INF/.../
outside of a request. I need it in a bean loaded at server startup.
A
This is how you can do it if you just want to access it from a Service (not through ServletContext):
final DefaultResourceLoader loader = new DefaultResourceLoader();
Resource resource = loader.getResource("classpath:templates/mail/sample.png");
File myFile = resource.getFile();
Note that the last line may throw IOException
so you need to catch / rethrow
Note, that the file is here:
src\main\resources\templates\mail\sample.png