Is there a way I can run code before database connection?
I have a problem
Jenkins has a vault that stores the DB password. This vault property names do not accept lowercase, periods or dashes. and I believe it sets it on the OS system variables (I’m not very experienced with Docker)
So the setting main.datasource.username is now “MAIN_DATASOURCE_USERNAME”
I’m thinking on running some code as soon spring boot starts.
It would be right after the spring profile is read
later I get the keys and values of the sensitive variables from the OS (if possible), change the key back to lowercase with periods and update these variables before the database connection starts.
I run it and i get an error the URL is not recognized
I plan to read the value from the OS environment variable and start my application with
gradle bootRun -Pmain.datasource.url=${DB_URL_ENVVAR} -Pmain.datasource.username=${DB_USER_ENVVAR}
etc…