【发布时间】:2021-09-14 19:36:29
【问题描述】:
我收到以下错误 无法构建 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=metadata
然后添加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=filesystem:db/migration
application.props
spring.jpa.properties.hibernate.default_schema=my
spring.jpa.hibernate.ddl-auto=validate
将 V1__init.sql 移至 db\migrations
我的实体没有指定架构
@Entity
@Table(uniqueConstraints={
@UniqueConstraint(....})
})
public class SomeTable {...}
【问题讨论】:
标签: spring-boot hibernate jpa flyway