带有postgresql,flyway和hikari的springboot2:驱动程序声称不接受jdbcurl

     2022-06-10     342

关键词:

我已经将Spring Boot与PostgreSQL和Flyway一起使用了很长一段时间,直到现在几乎没有遇到任何无法解决的问题。我正在建立一个新项目,并且像往常一样,我试图将自定义配置保持在最低限度,希望Spring Boot知道如何配置大多数东西-通常是这样。但是现在尝试创建“ flywayInitializer” bean时出现错误。它是由以下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]

我在Macbook(Catalina 10.15)上运行了PostgreSQL 12.2,这是通过自制程序安装并启动的本地进程。我使用Spring Boot 2.2.4.Release如下(来自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尚未添加为数据源,但已添加为依赖项以供将来使用。现在,我正在我的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

我已经对错误消息进行了搜索,发现很多人在配置Hikari连接池时遇到了问题,该池现在是Spring Boot的默认设置,但是这些问题主要与多个数据源有关,这不是我所拥有的(然而)。我仍然尝试过,但是解决他们的问题没有帮助我。我发现的一个较旧的问题是,Hikari无法理解url属性,需要一个名为jdbcUrl的属性,但这也无济于事。

我真的不知道该怎么做,但是我认为它要么与Hikari连接池有关,要么可能与我的postgreSQL实例有关。我确实发现错误消息有点奇怪:“ org.postgresql.Driver claims不接受jdbcUrl”。它到底在声称什么?是否隐藏了另一个错误?有什么方法可以使其更详细吗?

非常感谢任何帮助或提示!

答案

正如汤米·施密特(Tommy Schmidt)正确指出的那样,我只是在网址中输入错字。用冒号代替圆点可以解决它,显然:

jdbc:postgresql://localhost:5432/tmt

使用上述网址,即可使用。

PostgreSQL ‘数据库不存在’ - Java Spring Boot、Flyway、Docker/PostgreSQL

】PostgreSQL‘数据库不存在’-JavaSpringBoot、Flyway、Docker/PostgreSQL【英文标题】:PostgreSQL‘databasedoesnotexist’-JavaSpringBoot,Flyway,Docker/PostgreSQL【发布时间】:2020-08-2818:16:02【问题描述】:我正在关注这个教程:https://www.youtube.com/watch?v=... 查看详情

无法为 PostgreSQL 表应用 Flyway 迁移

】无法为PostgreSQL表应用Flyway迁移【英文标题】:CannotapplyFlywaymigrationforaPostgreSQLtable【发布时间】:2021-08-2919:56:32【问题描述】:在我的Java应用程序中,我有以下迁移文件:--codeomittedforbrevitycreatetableifnotexistsdemo_table(idbigintnotnull,"... 查看详情

带有用户名和密码的 Zonky + Spring Boot + Postgres + Flyway

】带有用户名和密码的Zonky+SpringBoot+Postgres+Flyway【英文标题】:Zonky+SpringBoot+Postgres+FlywaywithUsernameandPassword【发布时间】:2019-11-2209:48:01【问题描述】:我们正在使用Zonky对由Postgres和Flyway支持的SpringBoot应用程序进行集成测试。一... 查看详情

无法在 Spring Boot 中将 Flyway 迁移与 postgresQL 连接起来

】无法在SpringBoot中将Flyway迁移与postgresQL连接起来【英文标题】:NotableconnectflywaymigrationwithpostgresSQLinspringboot【发布时间】:2020-03-1416:05:30【问题描述】:我正在使用PostgreSQL为spring-boot项目设置flyway迁移,但无法连接数据库并出... 查看详情

Flyway - 自动增量 ID 不适用于 PostgreSQL 中的测试数据

】Flyway-自动增量ID不适用于PostgreSQL中的测试数据【英文标题】:Flyway-autoincrementidnotworkingwithtestdatainPostgreSQL【发布时间】:2021-11-2500:53:55【问题描述】:在我将Flyway添加到我的项目之前,我可以运行POST请求并成功创建新用户,ID... 查看详情

在 JPA 中使用 Flyway 创建的序列

...迭代。JPA应该能够识别序列并使用它。我让Flyway执行一个PostgreSQL脚本:CREATESEQUENCEconfig_id_s 查看详情

如何在flyway创建的postgresql jdbc连接上设置时区?

】如何在flyway创建的postgresqljdbc连接上设置时区?【英文标题】:Howtosettimezoneonpostgresqljdbcconnectioncreatedbyflyway?【发布时间】:2020-02-0516:03:57【问题描述】:我有一个postgresql数据库,我使用flyway部署脚本。我使用mavenflyway插件来启... 查看详情

在 Maven 中使用带有 Flyway 和 jOOQ 的嵌入式数据库进行持续集成

】在Maven中使用带有Flyway和jOOQ的嵌入式数据库进行持续集成【英文标题】:UsingembeddeddatabasewithFlywayandjOOQinMavenforcontinuousintegration【发布时间】:2015-04-0818:40:07【问题描述】:所以我真的想用SQLthatwillbreakatcompiletimeusingflywayandjOOQ做... 查看详情

带有 Spring Boot 的 Flyway Core 给出错误 'delayedFlywayInitializer' 和 'entityManagerFactory' 之间的循环依赖关系

】带有SpringBoot的FlywayCore给出错误\\\'delayedFlywayInitializer\\\'和\\\'entityManagerFactory\\\'之间的循环依赖关系【英文标题】:FlywayCorewithSpringBootgiveserrorCirculardepends-onrelationshipbetween\'delayedFlywayInitializer\'and\'entityManag 查看详情

通过 Flyway SQL 脚本为 PostgreSQL 中新创建的列设置不为空

】通过FlywaySQL脚本为PostgreSQL中新创建的列设置不为空【英文标题】:SetnotnullforanewlycreatedcolumninPostgreSQLviaFlywaySQLscript【发布时间】:2021-05-1303:28:55【问题描述】:我有一个Flyway迁移脚本(在我们的SpringBoot应用程序中):altertableb... 查看详情

Flyway - JDBC 查询

...-12-1715:41:15【问题描述】:我必须安装JDBC驱动程序才能在PostgreSQL中使用flyway吗?如果是-那么我必须下载哪个JDBC?我对数据迁移完全陌生-需要知道我必须安装哪个JDBC?【问题讨论】:jdbc.postgresql.org/download.htmlPostgreSQLJDBC4.2Driver,4... 查看详情

Flyway Core 和 Flyway Maven 插件有啥区别?

...0:14【问题描述】:我在我的Spring-Boot项目中使用Flyway(在带有maven的Eclipse中)与<dependency> 查看详情

如何最好地处理带有嵌入式数据库的 Flyway 以进行集成测试?

】如何最好地处理带有嵌入式数据库的Flyway以进行集成测试?【英文标题】:HowbesttohandleFlywaywithembeddedDBforintegrationtests?【发布时间】:2015-12-2312:36:16【问题描述】:我有一个现有的应用程序,我最近开始使用Flyway,并且大部分... 查看详情

带有 groovy 环境的 flyway gradle 插件

】带有groovy环境的flywaygradle插件【英文标题】:flywaygradlepluginwithgroovyenvironments【发布时间】:2015-06-2418:53:15【问题描述】:我正在尝试自定义gradle来构建以从groovy文件中获取flyway属性我的environment.groovy文件environmentsdevflywayProperti... 查看详情

如何将 Flyway 迁移与单个架构和多个项目一起使用

...本如果被其他项目修改,则不允许启动。例如:我有一个带有FlywayInitializer类的SpringBootProje 查看详情

PostgreSQL 通知和带有 Rails 的 WebSockets

】PostgreSQL通知和带有Rails的WebSockets【英文标题】:PostgreSQLnotificationsandWebSocketswithRails【发布时间】:2013-03-2015:05:30【问题描述】:是否有任何Ruby/Rails库用于通过WebSockets发送PostgreSQLasynchronousnotifications?我需要通知浏览器客户端... 查看详情

带有更新和选择语句的 PostgreSQL 返回表导致歧义

】带有更新和选择语句的PostgreSQL返回表导致歧义【英文标题】:PostgreSQLreturntablewithupdateandselectstatementcausingambiguity【发布时间】:2013-04-2801:15:22【问题描述】:我正在为我的一个朋友开发一个小型艺术画廊网站,出于各种原因决... 查看详情

如何使用 Spring Boot 和 Flyway 为 Quartz 调度程序设置数据库模式?

...】:我有一个SpringBoot应用程序,它使用Quartz调度程序和PostGreSQL数据库作为存储。我正在将其从使用public架构的自己 查看详情