FlywayException: Validate failed: Detected resolved migration not applied to database: 1.0.020190110

flyway 新老版本兼容异常 Validate failed: Detected resolved migration not applied to database

异常信息

2019-01-11 17:20:52.680  INFO 32204 --- [           main] utoConfigurationReportLoggingInitializer : 

Error starting ApplicationContext. To display the auto-configuration report re-run your application with 'debug' enabled.
2019-01-11 17:20:52.714 ERROR 32204 --- [           main] o.s.boot.SpringApplication               : Application startup failed

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.FlywayException: Validate failed: Detected resolved migration not applied to database: 1.0.020190110
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1628)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:555)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483)
	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:761)
	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:867)
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:543)
	at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122)
	at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:693)
	at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:360)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:303)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1118)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1107)
	at com.jfintech.jbs.JeanBourgetApplication.main(JeanBourgetApplication.java:40)
Caused by: org.flywaydb.core.api.FlywayException: Validate failed: Detected resolved migration not applied to database: 1.0.020190110
	at org.flywaydb.core.Flyway.doValidate(Flyway.java:1286)
	at org.flywaydb.core.Flyway.access$100(Flyway.java:71)
	at org.flywaydb.core.Flyway$1.execute(Flyway.java:1176)
	at org.flywaydb.core.Flyway$1.execute(Flyway.java:1168)
	at org.flywaydb.core.Flyway.execute(Flyway.java:1650)
	at org.flywaydb.core.Flyway.migrate(Flyway.java:1168)
	at org.springframework.boot.autoconfigure.flyway.FlywayMigrationInitializer.afterPropertiesSet(FlywayMigrationInitializer.java:66)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1687)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1624)
	... 16 common frames omitted

错误原因分析

Validate failed: Detected resolved migration not applied to database: 1.0.020190110

出现这个异常原因sql版本校验没过,正常情况一般是版本命名不规范,修改sql版本即可。于是检查数据库中flyway_schema_history的version并没有发现有何不对
在这里插入图片描述

解决方法

1、删除flyway_schema_history表中数据,启动项目错误还是存在
2、放大招删flyway_schema_history 表,启动项目错误依然存在,但此时日志中出现一条警告:

2019-01-14 13:35:03.829  WARN 27816 --- [           main] o.f.c.i.s.JdbcTableSchemaHistory         : Could not find schema history table `jfintech_jean_bourget`.`flyway_schema_history`, but found `jfintech_jean_bourget`.`schema_version` instead. You are seeing this message because Flyway changed its default for flyway.table in version 5.0.0 to flyway_schema_history and you are still relying on the old default (schema_version). Set flyway.table=schema_version in your configuration to fix this. This fallback mechanism will be removed in Flyway 6.0.0.

提示信息已经很明显了,仔细一看数据库种确实有一张schema_version的表,而且里面的version和现在sql文件的命名规则不一致。
原来是之前使用了flyway 5.0.0以前的版本,5.0.0以前的版本默认的版本管理表名是schema_version,5.0.0以后默认表名是flyway_schema_history,6.0.0之前会做兼容,6.0.0之后就会去除此兼容。官方建议在配置中设置flyway.table=schema_version

flyway 兼容源码:

   public boolean exists() {
        if(!this.tableFallback && this.table.getName().equals("flyway_schema_history")) {
            Table fallbackTable = this.table.getSchema().getTable("schema_version");
            if(fallbackTable.exists()) {
                LOG.warn("Could not find schema history table " + this.table + ", but found " + fallbackTable + " instead. You are seeing this message because Flyway changed its default for flyway.table in version 5.0.0 to flyway_schema_history and you are still relying on the old default (schema_version). Set flyway.table=schema_version in your configuration to fix this. This fallback mechanism will be removed in Flyway 6.0.0.");
                this.tableFallback = true;
                this.table = fallbackTable;
            }
        }

3、删除 schema_version 问题解决

使用版本及配置

版本:

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

配置:

flyway:
  locations: classpath:/db
  baseline-on-migrate: true
  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
出现“failed to run kubelet: validate service connection: validate cri v1 runtime”错误是因为Kubernetes的kubelet服务在验证与容器运行时(CRI V1 Runtime)的连接时出现了问题。 Kubernetes的kubelet是集群中每个节点上的主要组件,负责管理容器的创建、启动、停止和销毁。与容器运行时配合使用可以实现容器管理的功能。CRI(Container Runtime Interface)是Kubernetes定义的容器运行时接口,用于与底层容器运行时通信。 出现“validate cri v1 runtime”错误可能有以下几个原因: 1. 容器运行时不兼容:可能kubelet正在与不兼容的容器运行时进行通信。请确保kubelet和容器运行时的版本兼容,并且与Kubernetes集群的版本保持一致。 2. CRI插件未正确安装或配置:kubelet通过CRI插件与容器运行时进行通信。请确保CRI插件已正确安装,并且kubelet的配置文件中已正确配置CRI插件的相关参数。 3. 容器运行时服务不可用:kubelet无法连接到运行容器运行时的服务。检查容器运行时的服务是否已正确启动,并且网络连接是否正常。 解决“validate cri v1 runtime”错误可以采取以下步骤: 1. 检查kubelet和容器运行时的版本是否兼容,确保与Kubernetes集群的版本保持一致。 2. 检查CRI插件是否正确安装,并且kubelet的配置文件中已正确配置CRI插件的相关参数。 3. 检查容器运行时的服务是否已正确启动,并且网络连接是否正常。 4. 如果上述步骤都没有解决问题,可以尝试重新安装和配置Kubernetes集群,确保正确安装和配置kubelet和容器运行时。 总之,出现“failed to run kubelet: validate service connection: validate cri v1 runtime”错误一般是由于kubelet与容器运行时的连接验证问题引起的,需要检查版本兼容性、CRI插件配置和容器运行时服务是否正常运行等方面的问题来解决。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值