After upgrading to 2.5.0, this data source configuration:
spring:
datasource:
type: org.h2.jdbcx.JdbcDataSource
url: jdbc:h2:mem:database
username: sa
password: password
fails with the following exception:
Caused by: org.springframework.boot.jdbc.UnsupportedDataSourcePropertyException: No mapping found for driverClassName
at org.springframework.boot.jdbc.UnsupportedDataSourcePropertyException.throwIf(UnsupportedDataSourcePropertyException.java:36) ~[spring-boot-2.5.0.jar:2.5.0]
at org.springframework.boot.jdbc.DataSourceBuilder$MappedDataSourceProperties.getMapping(DataSourceBuilder.java:344) ~[spring-boot-2.5.0.jar:2.5.0]
at org.springframework.boot.jdbc.DataSourceBuilder$MappedDataSourceProperties.set(DataSourceBuilder.java:332) ~[spring-boot-2.5.0.jar:2.5.0]
at org.springframework.boot.jdbc.DataSourceBuilder.build(DataSourceBuilder.java:179) ~[spring-boot-2.5.0.jar:2.5.0]
at org.springframework.boot.autoconfigure.jdbc.DataSourceConfiguration$Generic.dataSource(DataSourceConfiguration.java:150) ~[spring-boot-autoconfigure-2.5.0.jar:2.5.0]
at jdk.internal.reflect.GeneratedMethodAccessor66.invoke(Unknown Source) ~[na:na]
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
at java.base/java.lang.reflect.Method.invoke(Method.java:566) ~[na:na]
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154) ~[spring-beans-5.3.7.jar:5.3.7]
... 87 common frames omitted
I took a quick look and it seems like the H2DataSourceProperties
only supports three properties:
private static class H2DataSourceProperties extends MappedDataSourceProperties<JdbcDataSource> {
H2DataSourceProperties() {
add(DataSourceProperty.URL, JdbcDataSource::getUrl, JdbcDataSource::setUrl);
add(DataSourceProperty.USERNAME, JdbcDataSource::getUser, JdbcDataSource::setUser);
add(DataSourceProperty.PASSWORD, JdbcDataSource::getPassword, JdbcDataSource::setPassword);
}
}
The driverClassName
is not supported, but it will be set by DataSourceProperties#initializeDataSourceBuilder
:
public DataSourceBuilder<?> initializeDataSourceBuilder() {
return DataSourceBuilder.create(getClassLoader()).type(getType()).driverClassName(determineDriverClassName())
.url(determineUrl()).username(determineUsername()).password(determinePassword());
}
Comment From: snicoll
Thanks for the report. I believe this is a regression that may have been introduced by #25643
Comment From: snicoll
Postgres and Oracle are impacted in a similar fashion, I believe.