Closed m1h43l closed 3 years ago
Hi @m1h43l ,
I don't think there is a way to do this currently as-is.
I'm hesitant to add new config options since the options that exist are already one-off options unique to the jbatch impl and not especially following any common, well-known patterns.
One option a user could do would be to configure the jbatch runtime themselves programmatically using its SPI.
E.g. you could extend DatabaseConfigurationBean with MyDatabaseConfigurationBeanExt and do something like this
BatchSPIManager batchSPIManager = BatchSPIManager.getInstance();
DatabaseConfigurationBean databaseConfigurationBean = new MyDatabaseConfigurationBeanExt();
batchSPIManager.registerDatabaseConfigurationBean(databaseConfigurationBean);
If you do this early, before jbatch "hardens" its initialization based on its config you should be able to implement a bean providing userid/password from env vars or sysprops.
How does that sound?
implement a bean providing userid/password from env vars or sysprops.
Actually this is one of the options I was also thinking about. Thanks for confirming this approach.
It seems that in SE mode the only way to set the username and password for the database config is the provide the creds in the batch-config.properties file.
I would rather have them additionally read from System Properties or environment variables.
How to provide the credentials for database access in a flexible way without the need to hardcode it in a properties file and repackage the application?