I have application.yml file:
spring:
datasource:
driver-class-name: org.postgresql.Driver
url: jdbc:postgresql://localhost:5432/my_db
username: my_user
password: password123
I want to change this file & insert values by VM options:
spring:
datasource:
driver-class-name: org.postgresql.Driver
url: ${dbUrl:jdbc:postgresql://localhost:5432/my_db}
username: ${dbUser:my_user}
password: ${dbPassword:password123}
With defining these variables with VM options:
gradle test --stacktrace -DdbUrl=jdbc:postgresql://postgres-master:5432/another_db \
-DdbUser=another_user \
-DdbPassword=password456
I expect that when these VM options available, it shall replace values in application.yml. But as logs shows, gradle task not find or not recognize these options & fail with stacktrace:
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException at ConstructorResolver.java:800
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException at ConstructorResolver.java:800
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException at ConstructorResolver.java:800
Caused by: org.springframework.beans.factory.BeanCreationException at AbstractAutowireCapableBeanFactory.java:1786
Caused by: org.flywaydb.core.internal.exception.FlywaySqlException at JdbcUtils.java:68
Caused by: org.postgresql.util.PSQLException at ConnectionFactoryImpl.java:303
Caused by: java.net.ConnectException at PlainSocketImpl.java:-2
How to add values into application.yml with gradle task started?