Access files through classpath.
Springboot will scan /META-INF/resources/; /resources/; /static/ and/public/ folders when you tell it to find something in the “Classpath”.
Using Resource interface would instantiate an ClassPathResource.
Resource resource =new ClassPathResource("RelativePathOfYourFile, root of /META-INF/resources/; /resources/; /static/ or /public/"); try { String path =resource.getFile().getAbsolutePath(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); }