Spring Boot FlywayException:无法连接到数据库。配置网址、用户和密码
当我运行时,我收到错误maven flyway:migrate
未能在 project myProject: org.flywaydb.core.api.FlywayException: 無法執行 goal org.flywaydb:flyway-maven-plugin:6.5.5:migrate (default-cli) on project myProject: org.flywaydb.core.api.FlywayException: 無法連接到資料庫。配置网址,用户和密码!
我在 application.yml 文件中有我的 Spring Boot 设置,但我想这个错误意味着它没有检测到数据库配置。该文档说:“Spring Boot将自动将Flyway与其DataSource自动连接,并在启动时调用它。如果我在 flyway 插件部分将配置添加到我的 pom.xml,它会成功连接到数据库,但我希望它使用我的 application.yml 配置。不是绒球.xml。那么我做错了什么呢?
链接到有问题的存储库:https://github.com/jack-cole/BrokenSpringBoot
应用程序.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>