Retrieving Vault Values From Environment Variables or Pass Using Spring?

Hello,

I am looking for opinions on the advantages/disadvantages of accessing vault through different means.

I have my secrets stored in vault and I have considered two ways to access them.

  1. Setting an environment variable on the machine where my application is running and passing the environment variable as a parameter for the application to query the secret from the vault.

  2. Using a a Spring Dependency to connect and retrieve to the vault where the token and url would be passed as VM arguments to the Java application.

In terms of scalability and security which approach would you prefer?

Thank You.