spring boot - UnsupportedDataSourcePropertyException is thrown when attempting to set jdbcUrl for ProxyDataSource - Stack Overfl

admin2025-04-16  4

I am using Spring Boot 3.2.3 and HikariCP.

Additionally I use datasource proxy to enable jdbc tracing:

<dependency>
  <groupId>net.ttddyy</groupId>
  <artifactId>datasource-proxy</artifactId>
  <version>1.10</version>
</dependency>

I have the following application.properties configured:

jdbc.datasource-proxy.enabled=true

spring.liquibase.password=password
spring.liquibase.user=user

spring.datasource.password=password
spring.datasource.username=username
spring.datasource.url=jdbc:h2:mem:test

Issue: When starting my application this exception is thrown:

Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [liquibase.integration.spring.SpringLiquibase]: Factory method 'liquibase' threw exception with message: Unable to find suitable method for url
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:177)
    at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:647)
    ... 22 common frames omitted
Caused by: org.springframework.boot.jdbc.UnsupportedDataSourcePropertyException: Unable to find suitable method for url
    at org.springframework.boot.jdbc.UnsupportedDataSourcePropertyException.throwIf(UnsupportedDataSourcePropertyException.java:36)
    at org.springframework.boot.jdbc.DataSourceBuilder$ReflectionDataSourceProperties.getMethod(DataSourceBuilder.java:580)
    at org.springframework.boot.jdbc.DataSourceBuilder$ReflectionDataSourceProperties.get(DataSourceBuilder.java:570)
    at org.springframework.boot.jdbc.DataSourceBuilder.build(DataSourceBuilder.java:180)
    at org.springframework.boot.autoconfigure.liquibase.LiquibaseAutoConfiguration$LiquibaseConfiguration.getMigrationDataSource(LiquibaseAutoConfiguration.java:155)
    at org.springframework.boot.autoconfigure.liquibase.LiquibaseAutoConfiguration$LiquibaseConfiguration.createSpringLiquibase(LiquibaseAutoConfiguration.java:130)
    at org.springframework.boot.autoconfigure.liquibase.LiquibaseAutoConfiguration$LiquibaseConfiguration.liquibase(LiquibaseAutoConfiguration.java:101)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:568)
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:140)
    ... 23 common frames omitted

This exception is not thrown, when datasource proxy is disabled (jdbc.datasource-proxy.enabled=false) or when liquibase url is configured (spring.liquibase.url=jdbc:h2:mem:test).

My expectation here was, that the DataSourceBuilder derives the url from the ProxyDataSource. But in this case it looks like the DataSourceBuilder will look for setUrl or setURL in the ProxyDataSource class, but probably the derivation of the 'url' does not work here.

This issue could be a bit similar to this one: 73164791

Can someone have a look on my issue?

Thx for any support!

I am using Spring Boot 3.2.3 and HikariCP.

Additionally I use datasource proxy to enable jdbc tracing:

<dependency>
  <groupId>net.ttddyy</groupId>
  <artifactId>datasource-proxy</artifactId>
  <version>1.10</version>
</dependency>

I have the following application.properties configured:

jdbc.datasource-proxy.enabled=true

spring.liquibase.password=password
spring.liquibase.user=user

spring.datasource.password=password
spring.datasource.username=username
spring.datasource.url=jdbc:h2:mem:test

Issue: When starting my application this exception is thrown:

Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [liquibase.integration.spring.SpringLiquibase]: Factory method 'liquibase' threw exception with message: Unable to find suitable method for url
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:177)
    at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:647)
    ... 22 common frames omitted
Caused by: org.springframework.boot.jdbc.UnsupportedDataSourcePropertyException: Unable to find suitable method for url
    at org.springframework.boot.jdbc.UnsupportedDataSourcePropertyException.throwIf(UnsupportedDataSourcePropertyException.java:36)
    at org.springframework.boot.jdbc.DataSourceBuilder$ReflectionDataSourceProperties.getMethod(DataSourceBuilder.java:580)
    at org.springframework.boot.jdbc.DataSourceBuilder$ReflectionDataSourceProperties.get(DataSourceBuilder.java:570)
    at org.springframework.boot.jdbc.DataSourceBuilder.build(DataSourceBuilder.java:180)
    at org.springframework.boot.autoconfigure.liquibase.LiquibaseAutoConfiguration$LiquibaseConfiguration.getMigrationDataSource(LiquibaseAutoConfiguration.java:155)
    at org.springframework.boot.autoconfigure.liquibase.LiquibaseAutoConfiguration$LiquibaseConfiguration.createSpringLiquibase(LiquibaseAutoConfiguration.java:130)
    at org.springframework.boot.autoconfigure.liquibase.LiquibaseAutoConfiguration$LiquibaseConfiguration.liquibase(LiquibaseAutoConfiguration.java:101)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:568)
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:140)
    ... 23 common frames omitted

This exception is not thrown, when datasource proxy is disabled (jdbc.datasource-proxy.enabled=false) or when liquibase url is configured (spring.liquibase.url=jdbc:h2:mem:test).

My expectation here was, that the DataSourceBuilder derives the url from the ProxyDataSource. But in this case it looks like the DataSourceBuilder will look for setUrl or setURL in the ProxyDataSource class, but probably the derivation of the 'url' does not work here.

This issue could be a bit similar to this one: 73164791

Can someone have a look on my issue?

Thx for any support!

Share Improve this question asked Feb 4 at 7:20 user29484920user29484920 1
Add a comment  | 

1 Answer 1

Reset to default 0

I doing wrong in application.properties file. Proper properties file looks like this:

spring.datasource.url=jdbc:h2:mem:testdb
spring.datasource.driver-class-name=org.h2.Driver
spring.datasource.username=
spring.datasource.password=

spring.h2.console.enabled=true
spring.h2.console.path=/h2-console

Therefore, You have to add h2 database dependency.

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-jpa</artifactId>
    </dependency>
    <dependency>
        <groupId>com.h2database</groupId>
        <artifactId>h2</artifactId>
        <scope>runtime</scope>
    </dependency>
</dependencies>
转载请注明原文地址:http://anycun.com/QandA/1744736497a86894.html