0
votes

I've been using Spring Boot with PostgreSQL and Flyway for quite some time now, and hardly ever ran in any unsolvable problems until now. I'm setting up a new project, and as usual I'm trying to keep custom configuration at a minimum, expecting that Spring Boot will know how to configure most things - and usually it does. But now I'm getting an error when the "flywayInitializer" bean is trying to be created. It is caused by the following RuntimeException:

Caused by: java.lang.RuntimeException: Driver org.postgresql.Driver claims to not accept jdbcUrl, jdbc.postgresql://localhost:5432/tmt
at com.zaxxer.hikari.util.DriverDataSource.<init>(DriverDataSource.java:110) ~[HikariCP-3.4.2.jar:na]
at com.zaxxer.hikari.pool.PoolBase.initializeDataSource(PoolBase.java:321) ~[HikariCP-3.4.2.jar:na]

I have PostgreSQL 12.2 running on my Macbook (Catalina 10.15) as a local process installed and started via homebrew. I use Spring Boot 2.2.4.Release as follows (from pom.xml):

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.2.4.RELEASE</version>
    <relativePath/> <!-- lookup parent from repository -->
</parent>

<!-- groupId, etc. omitted -->

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <java.version>11</java.version>
    <hibernate.types.version>2.4.2</hibernate.types.version>
    <html.unit.version>2.36.0</html.unit.version>
    <jaxb.runtime.version>2.3.2</jaxb.runtime.version>
    <nv.i18n.version>1.26</nv.i18n.version>
    <spring.version>5.1.5.RELEASE</spring.version>
</properties>

<dependencies>
    <!--    ##############################
        ######              Dev             ######
        ############################## -->
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
    <!-- Spring AOP -->
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-aop</artifactId>
    </dependency>
    <!-- Spring Cache -->
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-cache</artifactId>
    </dependency>
    <!-- Spring Data -->
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-jpa</artifactId>
    </dependency>
    <!-- Spring Redis -->
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-redis</artifactId>
    </dependency>
<!-- other dependencies omitted -->
</dependencies>

Redis is not yet added as datasource, but already added as dependency for future use. Right now, I'm configuring my data source as follows in my application.yml:

spring:
    datasource:
        url: jdbc.postgresql://localhost:5432/tmt
        username: tmt
        password: *********
        driver-class-name: org.postgresql.Driver
    flyway:
        baselineOnMigrate: true
        locations: classpath:db/migration
    jpa:
        hibernate:
            ddl-auto: update
        generate-ddl: true
        properties:
            hibernate:
                dialect: org.hibernate.dialect.PostgreSQL9Dialect
                jdbc:
                    lob:
                    non_contextual_creation: true

I've googled the error message and found that quite a few people had problems with configuring the Hikari connection pool that is now default with Spring Boot, but these problems were mostly related to multiple datasources, which is not what I'm having (yet). I still tried, but no solution to their issues helped me. An older issue I found was that Hikari wouldn't understand the url property and needed one called jdbcUrl, but this didn't help either.

I really have no idea what I could be doing wrong, but I assume that it is either related to the Hikari connection pool or maybe it has to do with my postgreSQL instance. I do find the error message a bit strange: "org.postgresql.Driver claims to not accept jdbcUrl". What exactly is it claiming? Is there another error hidden? Is there any way to make it more verbose?

Any help or hint is greatly appreciated!

1
your jdbc url is wrong i think. try jdbc:postgresql://localhost:5432/tmt - Tommy Schmidt
Thank you! I've spend a whole afternoon with this. No idea how I could not see that I used a dot instead of a colon. - Serg Derbst
glad that solved the issue ^^ - Tommy Schmidt

1 Answers

0
votes

As Tommy Schmidt correctly pointed out, I was simply having a typo in my url. Replacing the dot with a colon solved it, obviously:

jdbc:postgresql://localhost:5432/tmt

With the above url it works.