HikariPool-1 - jdbcUrl is required with driverClassName

后端 未结 2 1606
离开以前
离开以前 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();
    }
    

提交回复
热议问题