spring-boot - Spring Boot gradle flyway - 验证错误 - 模式验证:缺少表
问题描述
我收到以下错误 无法构建 Hibernate SessionFactory;嵌套异常是 org.hibernate.tool.schema.spi.SchemaManagementException: Schema-validation: missing table [my.table]
这是任何版本问题吗?大多数示例甚至官方都不使用模式? https://github.com/spring-projects/spring-boot/tree/main/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-flyway
数据库:MariaDB
步骤:使用创建 V1__init.sql
#spring.jpa.properties.javax.persistence.schema-generation.scripts.action=create #spring.jpa.properties.javax.persistence.schema-generation.scripts.create-target=V1__init.sql #spring.jpa.properties .javax.persistence.schema-generation.scripts.create-source=元数据
然后添加了flyway插件
flyway.properties 与 build.gradle 处于同一级别
flyway.user=py1***
flyway.password=ENC(aCUoPgiA+ZyHDFdrEXa)
flyway.schemas=我的
flyway.createSchemas=false
flyway.url=jdbc:mariadb://localhost:3306/my
flyway.locations=文件系统:db/migration
应用程序.props
spring.jpa.properties.hibernate.default_schema=my
spring.jpa.hibernate.ddl-auto=验证
将 V1__init.sql 移至 db\migrations
我的实体没有指定架构
@Entity
@Table(uniqueConstraints={
@UniqueConstraint(....})
})
public class SomeTable {...}
解决方案
添加依赖项 - 实现 'org.flywaydb:flyway-core' 并已解决
(关于 json 类型列的下一个错误 - 找到 [longtext (Types#LONGVARCHAR)],但期望 [json (Types#VARCHAR)] 不在本文讨论范围内)
推荐阅读
- android - 从 Android 中的 JSON 响应访问嵌套对象
- c++ - Haskell 线程何时加入?
- java - 两个类的可比性:一个泛型类,一个带有 char 字符的字符频率类
- pandas - 使用 dask read_csv 读取文件名作为列名
- python - 使用多列对熊猫数据框进行列表理解的内存有效方法
- react-native - 可以管理对 react-native-video 播放器的关注吗?
- python - 如何通过 DFS 遍历获得边权重和节点节点
- git - 如何根据最后一个分支合并名称自动增加标签?
- mysql - 无法连接到通过 Homebrew 安装的 MySQL @127.0.0.1
- mysql - Why do i get this error when trying to create a new table mysql?