In my Spring Boot app, I have the following values in my .env file located in the project root:
.env:
DB_NAME=demo_db
DB_USERNAME=postgres
DB_PASSWORD=pass
On the other hand, when I set environment variebles on the Run configuration of IntelliJ as shown below, it is working:
DB_NAME=demo_db;DB_USERNAME=postgres;DB_PASSWORD=pass
So, I have the following questions:
1. As far as I know, .env file is used to keep environment variables instead of setting. Is that true? Could you explain the usage of it a little bit more (I look at several pages but not a brief explanation).
2. Is there any relation of .env file with application.properties except from reading variable values from .env file? I am not sure if there may also be different version o .env file e.g. .env-dev file ?
Apparently you are mixing up spring boot and InteliJ.
If you are looking to run the application detacted from IDE you should define them in application.propeties defining them in a profile specific approach. Consider this article from offical spring docs.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With