I somehow can’t tell my client to read the configs correctly.
To make it short, my Spring Config Server (SCC) works correctly and with http / curl I can access the configurations correctly. For my dev environment I do have in my remote branch “dev” this application-dev.yml in my SSC:
# Common Configurations - Datasource
mysql:
url: jdbc:mysql://localhost:3306
username: root
password: test-password
jpa:
hibernate:
ddl-auto: update
show-sql: true
test:
database:
replace: none
# Location Service
EMP_LOC-S:
schema: location_db
# Employee Service
EMP_EMP-S:
schema: employee_db
# Customer Service
EMP_CUS-S:
schema: ${EMP_SCHEMA_CUSTOMER}
# Supplier Service
EMP_SUP-S:
schema: ${EMP_SCHEMA_SUPPLIER}
# Inventory Service
EMP_INV-S:
schema: ${EMP_SCHEMA_INVENTORY}
# Product Service
EMP_PRD-S:
schema: ${EMP_SCHEMA_PRODUCT}
Here is my “application-dev.yml” in my Spring Config Client – Location-Service (LOC-S).
# Connecting with Spring Cloud Config Server (CNF-S) - dev environment
spring:
config:
import: optional:configserver:${BASE_URL}:8888
cloud:
config:
label: dev
uri: ${BASE_URL}:8888
username: ${EMP_CONFIG_USERNAME}
password: ${EMP_CONFIG_PASSWORD}
# Datasource configuration for MySQL Server - LocationDB
datasource:
url: ${mysql.url}/${EMP_LOC-S.schema}
username: ${mysql.username}
password: ${mysql.password}
jpa:
hibernate:
ddl-auto: ${jpa.hibernate.ddl-auto}
show-sql: ${jpa.show-sql:true}
test:
database:
replace: ${test.database.replace}
But unfortunately I do get this error here:
Caused by: java.lang.IllegalArgumentException: URL must start with 'jdbc'
at org.springframework.util.Assert.isTrue(Assert.java:111) ~[spring-core-6.1.12.jar:6.1.12]
at org.springframework.boot.jdbc.DatabaseDriver.fromJdbcUrl(DatabaseDriver.java:284) ~[spring-boot-3.3.3.jar:3.3.3]
at org.springframework.boot.autoconfigure.jdbc.DataSourceProperties.determineDriverClassName(DataSourceProperties.java:180) ~[spring-boot-autoconfigure-3.3.3.jar:3.3.3]
at org.springframework.boot.autoconfigure.jdbc.PropertiesJdbcConnectionDetails.getDriverClassName(PropertiesJdbcConnectionDetails.java:49) ~[spring-boot-autoconfigure-3.3.3.jar:3.3.3]
at org.springframework.boot.autoconfigure.jdbc.DataSourceConfiguration.createDataSource(DataSourceConfiguration.java:55) ~[spring-boot-autoconfigure-3.3.3.jar:3.3.3]
at org.springframework.boot.autoconfigure.jdbc.DataSourceConfiguration$Hikari.dataSource(DataSourceConfiguration.java:117) ~[spring-boot-autoconfigure-3.3.3.jar:3.3.3]
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103) ~[na:na]
at java.base/java.lang.reflect.Method.invoke(Method.java:580) ~[na:na]
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:146) ~[spring-beans-6.1.12.jar:6.1.12]
... 38 common frames omitted
Process finished with exit code 0
I was looking for the root cause, but I simply can’t figure it out.
Thank you all for the support and I hope this isn’t a duplicate.
Peace!
2