HikariPool-1 - jdbcUrl is required with driverClassName

后端 未结 2 1581
离开以前
离开以前 2021-02-05 08:51

I went back to programming my old program https://github.com/JonkiPro/REST-Web-Services. I\'ve updated Spring Boot from version 15.6 to version 2.0.0. I have encountered many pr

相关标签:
2条回答
  • 2021-02-05 09:07

    I had the same issue in another context. From the 79. Data Access - Configure a Custom DataSource

    if you happen to have Hikari on the classpath, this basic setup does not work, because Hikari has no url property (but does have a jdbcUrl property)

    Hikari is the default pool in spring boot 2.

    so you can replace the config url: jdbc:postgresql:database -> jdbc-url: jdbc:postgresql:database

    or you can keep the config but you need to define another Bean to handle the mapping (aliases)

    @Bean
    @Primary
    @ConfigurationProperties("app.datasource")
    public DataSourceProperties dataSourceProperties() {
        return new DataSourceProperties();
    }
    
    @Bean
    @ConfigurationProperties("app.datasource")
    public DataSource dataSource(DataSourceProperties properties) {
        return properties.initializeDataSourceBuilder().
            .build();
    }
    
    0 讨论(0)
  • 2021-02-05 09:14

    Either remove spring.datasource.driver-class-name property or rename the spring.datasource.url property to spring.datasource.jdbc-url.

    This is reported in your error:

    java.lang.IllegalArgumentException: jdbcUrl is required with driverClassName

    First option looks cleaner and Spring Boot will figure out the default driver class name based on the spring.datasource.url property value (see org.springframework.boot.jdbc.DatabaseDriver class if you want to debug this).

    0 讨论(0)
提交回复
热议问题