I have the clean architecture project setup
Identity
| — Core
| — build.gradle.kts
| — Web
| — src
| — main
| — resources
| — application.properties
| — build.gradle.kts
| — External
| — build.gradle.kts
| — settings.gradle.kts
settings.gradle.kts
rootProject.name = "Identity"
include("Web")
include("Core")
include("External")
In the web project, I have the database connection string in application.properties as below
spring.datasource.driver-class-name= org.postgresql.Driver
spring.datasource.url=jdbc:postgresql://localhost:5432/school_staff
spring.datasource.username=keycloak
spring.datasource.password=******
Now in the external project, I have the flyway libraries below
plugins {
id("java-library")
id("org.flywaydb.flyway") version "11.0.1"
}
repositories {
mavenCentral()
}
dependencies {
implementation("org.springframework.boot:spring-boot-starter-data-jpa:3.4.0")
implementation("org.postgresql:postgresql:42.7.4")
implementation("org.flywaydb:flyway-core:11.0.1")
implementation("org.flywaydb:flyway-database-postgresql:11.0.1")
implementation("org.flywaydb:flyway-gradle-plugin:11.0.1")
}
I am using flyway gradle plugin and then When I run the migration command from the Identity location
./gradlew flywayMigrate
Exception
Starting a Gradle Daemon (subsequent builds will be faster)
> Task :External:flywayMigrate FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':External:flywayMigrate'.
> Error occurred while executing flywayMigrate
Unable to connect to the database. Configure the url, user and password!
The command not able to find the db connection. I don’t want to duplicate the connection string, I want the gradle command to pick up the connection string from the application.properties
file