0

Using ActiveJDBC (version 1.4.13), I can't find a way to override the database.properties bundled with the application (the one from src/main/resources/database.properties ending inside the jar).

Is there a way to override it with a local file (in the same vein as with application.properties in Spring Boot)?

Marco Pantaleoni
  • 2,529
  • 15
  • 14

1 Answers1

0

Please, see documentation here: http://javalite.io/database_connection_management#using-system-property

Basically, provide the location of your database.properties file as a system property:

java com.company.project.Main -cp myprogram.jar -Denv.connections.file=/path/to/file/database.properties

However, if it does not work for you, it is because of this bug that was fixed in Feb 2018:

https://github.com/javalite/activejdbc/issues/681

so, if this configuration does not work, keep in mind that the file is searched on the classpath. This means that if you put your file somewhere on the file system and list the directory of this file first on your classpath, your file will be found first as opposed to the one packaged into the Jar file.

So, if your file is: /opt/project/dir1/database.properties, you can start your process:

java -classpath /opt/project/dir1/:$CLASSPATH com.yourcompany.Main

then the file /opt/project/dir1/database.properties will be loaded first.

ipolevoy
  • 5,432
  • 2
  • 31
  • 46
  • for some reason I can't get it to work (on Windows). I've tried multiple combinations without success (with forward and backword slashes, using ";" to separate the paths, ...) – Marco Pantaleoni Apr 26 '18 at 11:26
  • this is just setting the classpath properties, not specific to JavaLite. Ensure your file is mentioned before anything else on the classpath. – ipolevoy Apr 30 '18 at 17:28