there. I'm new to Java Spring Boot and I'm trying to set environment variables in application.yml.
I've added dotenv maven dependency:
<!-- https://mvnrepository.com/artifact/io.github.cdimascio/java-dotenv --> <dependency> <groupId>io.github.cdimascio</groupId> <artifactId>java-dotenv</artifactId> <version>5.1.3</version> </dependency> I've set variables in the .env file:
SPRING_DATABASE_URL = jdbc://db_url SPRING_DATABASE_USERNAME = username SPRING_DATABASE_PASSWORD = password And in my application.yml:
spring: datasource: url: ${SPRING_DATABASE_URL} username: ${env.SPRING_DATABASE_USERNAME} password: ${env.SPRING_DATABASE_PASSWORD} While running application I'm getting jdbc error:
java.lang.RuntimeException: Driver org.postgresql.Driver claims to not accept jdbcUrl, ${SPRING_DATABASE_URL}
I've tried some solutions like:
export SPRING_DATABASE_URL = jdbc://db_url or in application.yml:
url: ${env.SPRING_DATABASE_URL} or
url: ${env.SPRING.DATABASE.URL} or
url: ${SPRING.DATABASE.URL} Am I doing something wrong or missing? I appreciate your help, thank you.
SPRING_DATSOURCE_URLas the environment variable and skip the mapping between variable names?