最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

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

programmeradmin0浏览0评论

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: .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 .springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:177)
    at .springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:647)
    ... 22 common frames omitted
Caused by: .springframework.boot.jdbc.UnsupportedDataSourcePropertyException: Unable to find suitable method for url
    at .springframework.boot.jdbc.UnsupportedDataSourcePropertyException.throwIf(UnsupportedDataSourcePropertyException.java:36)
    at .springframework.boot.jdbc.DataSourceBuilder$ReflectionDataSourceProperties.getMethod(DataSourceBuilder.java:580)
    at .springframework.boot.jdbc.DataSourceBuilder$ReflectionDataSourceProperties.get(DataSourceBuilder.java:570)
    at .springframework.boot.jdbc.DataSourceBuilder.build(DataSourceBuilder.java:180)
    at .springframework.boot.autoconfigure.liquibase.LiquibaseAutoConfiguration$LiquibaseConfiguration.getMigrationDataSource(LiquibaseAutoConfiguration.java:155)
    at .springframework.boot.autoconfigure.liquibase.LiquibaseAutoConfiguration$LiquibaseConfiguration.createSpringLiquibase(LiquibaseAutoConfiguration.java:130)
    at .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 .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: .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 .springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:177)
    at .springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:647)
    ... 22 common frames omitted
Caused by: .springframework.boot.jdbc.UnsupportedDataSourcePropertyException: Unable to find suitable method for url
    at .springframework.boot.jdbc.UnsupportedDataSourcePropertyException.throwIf(UnsupportedDataSourcePropertyException.java:36)
    at .springframework.boot.jdbc.DataSourceBuilder$ReflectionDataSourceProperties.getMethod(DataSourceBuilder.java:580)
    at .springframework.boot.jdbc.DataSourceBuilder$ReflectionDataSourceProperties.get(DataSourceBuilder.java:570)
    at .springframework.boot.jdbc.DataSourceBuilder.build(DataSourceBuilder.java:180)
    at .springframework.boot.autoconfigure.liquibase.LiquibaseAutoConfiguration$LiquibaseConfiguration.getMigrationDataSource(LiquibaseAutoConfiguration.java:155)
    at .springframework.boot.autoconfigure.liquibase.LiquibaseAutoConfiguration$LiquibaseConfiguration.createSpringLiquibase(LiquibaseAutoConfiguration.java:130)
    at .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 .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=.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>.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-jpa</artifactId>
    </dependency>
    <dependency>
        <groupId>com.h2database</groupId>
        <artifactId>h2</artifactId>
        <scope>runtime</scope>
    </dependency>
</dependencies>

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论