gpt4 book ai didi

spring - 使用 Spring Boot 的 Flyway 迁移错误详细信息

转载 作者:行者123 更新时间:2023-12-05 00:54:06 35 4
gpt4 key购买 nike

我们有一个使用 Spring Boot 和 flyway 的项目。

当我们运行迁移失败且日志级别全部设置为 DEBUG 时,我们只收到以下消息:

[DEBUG] org.flywaydb.core.internal.command.DbValidate - Validating migrations ...
[DEBUG] org.flywaydb.core.internal.scanner.Scanner - Filtering out resource: db/migration/V1/V1_202103081030__account.sql (filename: V1_202103081030__account.sql)
[DEBUG] org.flywaydb.core.internal.scanner.Scanner - Filtering out resource: db/migration/V1/V1_202103081040__place.sql (filename: V1_202103081040__place.sql)
[DEBUG] org.flywaydb.core.internal.scanner.Scanner - Filtering out resource: db/migration/V1/V1_202103151608__document.sql (filename: V1_202103151608__document.sql)
[DEBUG] org.flywaydb.core.Flyway - Memory usage: 147 of 254M
[ERROR] org.springframework.boot.web.embedded.tomcat.TomcatStarter - Error starting Tomcat context. Exception: org.springframework.beans.factory.UnsatisfiedDependencyException. Message: Error creating bean with name 'webSecurityConfig': Unsatisfied dependency expressed through method 'setContentNegotationStrategy' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration$EnableWebMvcConfiguration': Unsatisfied dependency expressed through method 'setConfigurers' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'openEntityManagerInViewInterceptorConfigurer' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/JpaBaseConfiguration$JpaWebConfiguration.class]: Unsatisfied dependency expressed through method 'openEntityManagerInViewInterceptorConfigurer' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'openEntityManagerInViewInterceptor' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/JpaBaseConfiguration$JpaWebConfiguration.class]: Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'flywayInitializer' defined in class path resource [org/springframework/boot/autoconfigure/flyway/FlywayAutoConfiguration$FlywayConfiguration.class]: Invocation of init method failed; nested exception is org.flywaydb.core.api.exception.FlywayValidateException: Validate failed: Migrations have failed validation
...
[INFO ] org.apache.catalina.core.StandardService - Stopping service [Tomcat]
...
Caused by: org.flywaydb.core.api.exception.FlywayValidateException: Validate failed: Migrations have failed validation

没有关于失败原因的更多详细信息(失败的查询、不匹配的校验和......)。

我查看了 spring.flyway 应用程序属性,但在这里找不到任何帮助。

我们应该怎么做才能在服务器启动时在我们的日志中显示 flyway root 错误?

编辑:要清楚,问题不在于故障本身(在 Flyway 类中设置断点可以揭示源错误)。问题是日志中缺少错误详细信息。

最佳答案

我遇到了同样的问题,发现它与我使用的 Flyway 版本有关(Spring Boot 2.4.3,它使用 Flyway 7.1.1)。这是一个已知问题 2987 - Display all validate messages in exceptions , 固定在 Flyway 7.2.0 .

他们建议运行 flyway validate -outputType=json 作为一种解决方法,以获得详细的错误消息。我试过了,但仍然没有收到详细的错误消息。

对我有用的解决方案是升级到 Flyway 7.2.0,方法是在我的 pom 文件中指定版本:

<dependency>
<groupId>org.flywaydb</groupId>
<artifactId>flyway-core</artifactId>
<version>7.2.0</version>
</dependency>

关于spring - 使用 Spring Boot 的 Flyway 迁移错误详细信息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66640909/

35 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com