I am unable to locate the file while using ${user.dir} to avoid hardcoding in the @Config.Sources annotation of the Owner library in Java to locate the property file.
Using the absolute path to locate the file works for me perfectly as shown below
@Config.Sources(value="C:\\Users\\username\\eclipse-workspace\\MWAFW\\src\\test\\resources\\FrameworkConfig.properties")
public interface FrameworkConfig extends Config {
...
}
However, If I use
@Config.Sources(value="${user.dir}\\src\\test\\resources\\FrameworkConfig.properties")
public interface FrameworkConfig extends Config {
...
}
or
@Config.Sources(value="${user.dir}/src/test/resources/FrameworkConfig.properties")
public interface FrameworkConfig extends Config {
...
}
does not locate the properties file. Why is ${user.dir} not working for me in this case?
- I am using a maven-Java project on Intellij community edition
You can try below steps to solve it
Print the value of ${user.dir} to the console or log file to verify that it resolves to the expected directory
using an absolute path to the property file
In IntelliJ IDEA, you can set the working directory in the Run/Debug Configuration for your application try checking, make sure that the working directory is set correctly
Using classpath