简体   繁体   中英

Permission denied with embeded tomcat

I have a Spring boot application which tries to access files located in "/var/someDirectory"

Platform is: linux ubuntu 16

Server Application is: Embedded tomcat

here is the code:

    File file = new File("/var/testFile1.txt");
    if (file.createNewFile()) {
        System.out.println("File is created!");
    } else {
        System.out.println("File already exists.");
    }

but with exception:

java.io.IOException: Permission denied

Question:

How can I grant permissions to my application on '/var/' ?

sudo mkdir /var/someDirectory
sudo chown -R your_user /var/someDirectory

It is not about Java, honestly.

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