提问者:小点点

无法在Spring启动中将飞行路线迁移与 postgresSQL 连接


我正在使用PostgreSQLspring-boot项目设置flyway迁移,但无法连接数据库,出现以下异常。

无法对项目执行目标org . flywaydb:flyway-maven-plugin:6 . 0 . 8:migrate(default-CLI)open-feign:org . flywaydb . core . API . flywaydb异常:无法连接到数据库。配置网址,用户和密码!-

Spring引导版本:2.2.1.RELEASE

Maven:

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>
<dependency>
    <groupId>org.flywaydb</groupId>
    <artifactId>flyway-core</artifactId>
    <version>6.0.8</version>
</dependency>

<dependency>
    <groupId>org.postgresql</groupId>
    <artifactId>postgresql</artifactId>
    <scope>runtime</scope>
</dependency>

<plugin>
    <groupId>org.flywaydb</groupId>
    <artifactId>flyway-maven-plugin</artifactId>
    <version>6.0.8</version>
</plugin>

应用程序.yml


    spring:
      application:
        name: MIGRATE DEMO
      datasource:
        url: jdbc:postgresql://localhost:5432/DABASENAME
        driver-class-name: org.postgresql.Driver
        username: postgres
        password: root
        platform: postgres
        dbcp2:
          validation-query: SELECT 1
      jpa:
        datbase: POSTGRESQL
        database-platform: org.hibernate.dialect.PostgreSQL9Dialect
        show-sql: true
        generate-ddl: true
        properties:
          hibernate.jdbc.lob.non_contextual_creation: true
        hibernate:
          ddl-auto: validate

    flyway:
      user: postgres
      password: root
      schemas: DABASENAME
      url: jdbc:postgresql://localhost:5432/DABASENAME
      locations: filesystem:db/migration

提前致谢


共1个答案

匿名用户

最后,它的工作,下面的变化,我做的。

根据FlywayAutoConfiguration spring.flyway的预期,例如。

spring.flyway: 

无法读取如下属性

spring: 
    flyway: 
        user: ....

版本控制格式Vx.x__(描述)[V(大写字母)1.2(整数)__(两个下划线字符)]