Unable to access folder location war!\WEB-INF\classes\ in packaged war with Spring boot

340 views Asked by At

I want to access my resource folder path which is inside the packaged WAR created by spring boot. I have looked this link, which is to access specific file at some location but I am looking for just the folder location.

With WAR file getRealPath() / getAbsolutePath() does not work, below is the snippet

String contextPath = event.getServletContext().getRealPath("/WEB-INF/scripts/views/"); 

One more scenario wherein I want to access ImageMagic tool which is packaged inside war at "WEB-INF/classes/ImageMagick-6.6.1-5" location but it is not accessed by the im4java library. Providing any drive location like "C:/ImageMagick-6.6.1-5" will work.

String bindir = URLDecoder.decode(getClass().getClassLoader().getResource("ImageMagick-6.6.1-5").getPath());

Is there any workaround to access the location of directory inside WAR.

0

There are 0 answers