How to read my property in war correctly?

I have a problem regarding reading my property, I do it like this:

    FileInputStream fis;
    Properties properties = new Properties(System.getProperties());
    fis = new FileInputStream(Objects.requireNonNull(this.getClass().getClassLoader()

on the local machine, this works well, but when I deploy my application there is a problem:

Caused by: /content/MyProject-1.0-SNAPSHOT.war/WEB-INF/classes/ (No such file or directory)

When I try to see if there is a file I need, I find it, but java can’t find it.

Here is an approximate structure of my project:

src/main/java/entities/ – from here I try to read properties

src/main/resources/ – here is the path to my property

Leave a Comment