I am accessing the properties file in my code with
ClassName.class.getClassloader().getResourceAsStream("config/config.properties"));
and
this.getClass.getClassloader().getResourceAsStream("config/config.properties");
If the properties file is in the resources directory, everything works fine and I run the program with the maven exec plugin without any issues. I just have to call
mvn exec:java -Dexec.mainClass="MyMainClass"
But this approach as a big disadvantage. It includes the properties file
How do I change maven configuration so the 'config/config.properties' file is available to the maven exec plugin without being inside 'src' and without being included in the jar?
NOTE: Just to Clarify, I don't know where the necessary config file will be when the application runs in production. I just know it is in the classpath. This is why I need to use getResourceAsStream()
and I need it not to be included in the jar file.