首页 > 解决方案 > 无法使用 flyway 配置文件迁移 mysql 脚本

问题描述

我有一个 Maven 项目,我正在尝试使用 MySQL 脚本创建带有 flyway 的表。

下面是我的文件夹结构。 这是我的文件夹结构

我的配置文件包括

flyway.driver=com.mysql.jdbc.Driver
flyway.url=jdbc:mysql://127.0.0.1:3306/atm
flyway.user=root
flyway.password=root1234
flyway.locations=filesystem:/flyway/migrations
flyway.sqlMigrationPrefix=V
flyway.sqlMigrationSeparator=__
flyway.validateOnMigrate=true

这是 SQL 脚本文件。

CREATE TABLE `atm_table` (
  `id` int(11) NOT NULL,
  `name` varchar(45) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

当我执行命令mvn flyway:migrate -X时,它只创建flyway_schema_history表。在日志中,它显示为

[DEBUG] Unable to load config file: /Users/name/flyway.conf
[DEBUG] Loading config file: /Users/name/my-project/flyway/conf/flyway.conf
Loading class 'com.mysql.jdbc.Driver'. This is deprecated. The new driver class is 'com.mysql.cj.jdbc.Driver'. The driver is automatically registered via the SPI and manual loading of the driver class is generally unnecessary.
[INFO] Flyway Community Edition 6.5.0 by Redgate
[DEBUG] Scanning for filesystem resources at '/my-project/flyway/migrations'
[WARNING] Skipping filesystem location:/my-project/flyway/migrations (not found). Note this warning will become an error in Flyway 7.
Wed Sep 16 16:32:45 IST 2020 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.

似乎它不是指正确的文件位置(配置文件中给出的位置)。如何解决这个问题?

标签: mysqlmavenflyway

解决方案


这是文件上的命名。看起来您在版本之后有一个下划线。您需要有两 (2) 个。这是一个容易犯的错误。我知道,因为我把它搞砸了。这是一篇关于它的文章。

如果您没有正确的命名标准,Flyway 将忽略该文件。


推荐阅读