简体   繁体   中英

How to use files outside of war file on jetty server?

I want to use some files outside my war file. It is located in

/opt/jetty/webapps

Let's say I want to put some files into

/opt/jetty/resources

and use them from my project. How can I access them from java code? When I use a full path in the deployed project, it's not working (no logging done and no errors):

Files.readAllBytes(Paths.get("/opt/jetty/resources/config"))

If you need to read a file from the filesystem, you can access it directly. If your servlet doesn't see the file on your server, but does from the IDE, there might be a problem with privileges / access rights.

If your server runs under a different user, make sure that it has rights to read and write requred files. Otherwise you'll have a Permission Denied error.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM