Question

In a Maven project, I have a settings.ini file in this directory :

|-src/main/resources/configurations

The settings.ini file, needs to refer to another file, tempDB.sql under this directory :

|-src/main/resources/databases

So, I tried this relative path in my settings.ini file, but it didn't work:

temp_database = ../databases/tempDB.sql

How do I specify a relative path in my .ini file?

Was it helpful?

Solution 2

As the path will not be read by the .ini file itself, your code will use the project root directory as the start. In this case, you should use:

|-src/main/resources/databases/tempDB.sql

OTHER TIPS

Be careful with @renke's answer. This won't work in any environment other than your development environment, because the project's source will not be available in other environments. A better solution is to have the resource file reference the filename temp_database=resource/tempDB.sql, and then load the file as a classpath resource in java "classpath:" + tempDatabase (assuming tempDatabase holds the property value read from your ini file). If this file isn't supposed to be available to your java code then it shouldn't be in src/main/resource in the first place.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top