【发布时间】:2021-01-19 08:01:16
【问题描述】:
当我运行maven flyway:migrate 时,我得到了错误
未能执行目标 org.flywaydb:flyway-maven-plugin:6.5.5:migrate 项目 myProject 上的(默认 cli): org.flywaydb.core.api.FlywayException:无法连接到 数据库。配置url、用户和密码!
我的 application.yml 文件中有我的 Spring Boot 设置,但我猜这个错误意味着它没有检测到数据库配置。 This documention 说,“Spring Boot 将自动将 Flyway 与其 DataSource 自动连接,并在启动时调用它。”如果我在 flyway 插件部分将配置添加到我的 pom.xml 中,它会成功连接到数据库,但我希望它使用我的 application.yml 配置。不是 pom.xml。那我做错了什么?
有问题的回购链接:https://github.com/jack-cole/BrokenSpringBoot
application.yml
spring:
datasource:
driverClassName: org.postgresql.Driver
url: "jdbc:postgresql://localhost:5433/myDB"
username: postgres
password: test123
依赖关系:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jooq</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>42.2.16</version>
</dependency>
<dependency>
<groupId>org.flywaydb</groupId>
<artifactId>flyway-core</artifactId>
<version>7.0.0</version>
</dependency>
插件:
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.flywaydb</groupId>
<artifactId>flyway-maven-plugin</artifactId>
<version>6.5.5</version>
</plugin>
【问题讨论】:
-
您是否尝试过实现flyway-core依赖? mvnrepository.com/artifact/org.flywaydb/flyway-core/7.0.0
-
是的,我已经有了。我只是忘了把它写在我的问题中。
标签: java spring-boot maven flyway