I having file in the location
--src
--> main
--> config
--> application
--> context
--> reference
--> user
--> user.xml
where
--src
--> main
--> config
is in the classpath. Now I am trying to access the file using
Resource resource = new ClassPathResource("classpath**:/application/context/references/user/user.xml");
File file = resource.getFile();
But I getting FileNotFoundException
, I tried with
Resource resource = new ClassPathResource("classpath:/application/context/references/user/user.xml");
File file = resource.getFile();
too, but still I getting the exception. Can someone help me to understand the working of ClassPathResource
and right solution?
Use as below
Resource resource = new ClassPathResource("/application/context/references/user/user.xml");
File file = resource.getFile();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.