我正在尝试将 Flyway 与我的简单 maven 项目集成以进行学习。
我正在使用以下插件和配置:
<plugin>
<groupId>org.flywaydb</groupId>
<artifactId>flyway-maven-plugin</artifactId>
<version>4.0.3</version>
<dependencies>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.9</version>
</dependency>
</dependencies>
<configuration>
<url>jdbc:mysql://${database.host}:${database.port}/${database.schema}?useUnicode=true&characterEncoding=UTF-8&characterSetResults=UTF-8</url>
<user>${database.user}</user>
<password>${database.password}</password>
<sqlMigrationPrefix>V_</sqlMigrationPrefix>
<sqlMigrationSeparator>__</sqlMigrationSeparator>
<locations>
<location>filesystem:src/main/resources/db/migrations</location>
</locations>
</configuration>
</plugin>
Run Code Online (Sandbox Code Playgroud)
这是我的示例迁移 sql 的名称:
V_1__create_new_table.sql
Run Code Online (Sandbox Code Playgroud)
我不确定我做错了什么,但我不断收到以下异常:
org.flywaydb.core.api.FlywayException: Invalid version containing non-numeric characters. Only 0..9 and . are allowed. Invalid version: V.1
Run Code Online (Sandbox Code Playgroud)
我确实参考了以下问题,正如您在配置中看到的那样,我已经完成了要求的操作: 类似问题
您可以简单地尝试仅定义V为您的迁移前缀,并命名您的迁移文件V1__Create_New_Table.sql(这些是 Flyway 默认值)。
您定义V_为前缀和V_1__Create_New_Table.sql文件名的方式是导致问题的原因,因为这告诉 Flyway 此迁移是 version V.1,这当然是不正确的。
对于较少数量的版本,您可以使用以下方法:例如V1_1__Create_New_Table.sql,这将为您提供迁移版本1.1。
在您提供的相关 SO 答案中,建议的答案是V_用作前缀和_分隔符,而您已在插件配置__中将其定义为插件分隔符。
| 归档时间: |
|
| 查看次数: |
1955 次 |
| 最近记录: |